dongzangchui2072 2014-05-15 18:30
浏览 42
已采纳

Zend Framework 2,重定向到路由并将变量传递给新控制器

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条回答 默认 最新

  • duandi1919 2014-05-15 19:49
    关注

    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.
            ),
        ),
    ),
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 用AT89C52单片机设计一个温度测量与控制电路
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义
  • ¥15 嵌入式--定时器使用
  • ¥20 51单片机学习中的问题
  • ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
  • ¥15 Python中knn问题
  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库