简体   繁体   English

symfony如何在redirectToRoute中检索参数

[英]symfony how to retrieve parameters in redirectToRoute

I'm using symfony. 我正在使用symfony。 In one action, I fill in some form, use getData to get the filled in data and want to pass to another action to do query in database. 在一个动作中,我填写了一些表单,使用getData来获取填充的数据,并希望传递给另一个动作来在数据库中进行查询。

$input=$form['input']->getData();
return $this->redirectToRoute('anotherpage', array('input'=>$input ));

In action of anotherpage, how to retrieve the information of input? 在另一页的操作中,如何检索输入的信息? It shows no default value for it which means I'm not passing it correctly. 它没有显示默认值,这意味着我没有正确传递它。 Hope to get some help. 希望得到一些帮助。 THANKS. 谢谢。

If i understood you properly, you may try this: 如果我理解你,你可以试试这个:

Just define the default value in action where you try to recieve input 只需在尝试接收输入时定义操作的默认值

class SomeController extends Controller
{
    public function anotherAction($input = 'defaultValue')
    {
        // do somth with $input
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM