Я пытаюсь получить определенный параметр с Zend Framework 2. Например,Получение параметров в Zend Framework 2
// set the form to be used in the update templates view
$form = new EmailTemplateForm();
// gets the form method request (usually post)
$request = $this->getRequest();
// check to see if the request was a POST form request
if ($request->isPost()) {
// good to go
// filter the form values now
$email = new EmailTemplates();
$form->setInputFilter($email->getInputFilter());
// set the form data to hold all the values supplied by the form
// via $request->getPost()
$form->setData($request->getPost());
// now we will see if the form is valid
// we check if it is valid by the email form class we created
if ($form->isValid()) {
// it is valid
// pass the form to data to the filter class via exchangeArray()
$email->exchangeArray($form->getData());
$tpl_id = !empty($this->getRequest()->getParam('id'))
? $this->getRequest()->getParam('id') : null;
if ($this->getEmailTemplatesService()->modifyEmailTemplate($email, $tpl_id) === true) {
// the updated email template was inserted into the database successfully
// redirect to email template view
return $this->redirect()->toUrl('/admin/email-template');
} else {
// error occured..
// the error is logged automatically
// redirect to email template view
return $this->redirect()->toUrl('/admin/email-template/' . $tpl_id);
}
}
}
бы $ this-> GetRequest() -> GetParam ('ID') возвращают номер id из URL-адреса страницы? У меня есть маршрут создан, чтобы быть в формате:
'route' => '/admin[/][:action][/:id]',
Итак, если форма была отправлена (через POST) и соответствующий URL-адрес был/администратор/редактировать-шаблон/3 будет $ this-> GetRequest () -> getParam ('id') содержит 3?
Спасибо!
Да, если post url имеют одинаковый параметр, он будет работать, почему вы спрашиваете, а не пытаетесь? – Daimos
не смог проверить его прямо сейчас. Спасибо за помощь :) – user2101411