我在Zend Framework 2中实现了一个用于下新订单的表单,在提交表单后,我应该重定向到另一个路由,并在另一个控制器中使用orders.id
变量。
我尝试使用$this->redirect()->toRoute('confirm', array('param'=>$orderId));
,但它不工作。
也许我不知道如何在另一个confirmAction
控制器中获得该参数。
请给我一些例子。非常感谢。
1)由于这是一个路由问题,请在module.config.php文件中显示路由的内容。如果我不得不猜测,你可能没有在你的配置中正确配置"param"约束。
应该是这样的:
'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.
),
),
),