I implemented a form for placing new orders in Zend Framework 2 and after submitting the form I should redirect to another route and take the orders.id
variable in another controller.
I tried using $this->redirect()->toRoute('confirm', array('param'=>$orderId));
but it is not working at all.
Maybe I do not know how to get that parameter in another confirmAction
controller.
Please give me some examples. Thank you very much.
1) Since this is a routing issue, show what you have for the route in the module.config.php file. You might not have the "param" constraint configured properly in your config if I had to guess.
It should look something like this:
'confirm' => array(
'type' => 'segment',
'options' => array(
'route' => '/controller_name/confirm[/][:param][/]',
'constraints' => array(
'param' => '[0-9]*'
),
'defaults' => array(
'__NAMESPACE__' => 'your_namespace', // ex. Application\Controller
'action' => 'confirm', // or whatever action you're calling
'controller' => 'controller_name' // ex.
),
),
),