Symfony - 重定向到填写了表单值的操作
如何重定向到另一个操作,并在新操作上填写表单字段?
我有一个操作,我想调用redirect(),例如:
$this->redirect('foo/search?Search[last_name]='.$this->form->getValue('last_name'));
哪个应该重定向到我的搜索操作,并且该操作中的表单应该填写last_name参数。该操作的代码如下:
public function executeSearch(sfWebRequest $request)
{
$this->form = new SearchForm();
$submission = $request->getParameter($this->form->getName());
...do stuff with $submission...
SearchForm具有名称格式“搜索[%s]”。
我对重定向()的参数所做的任何尝试都不起作用。 Search[] 参数总是会以某种方式搞乱并且不会填充表单。
How can I do a redirect to another action, and get the form fields to be filled in on the new action?
I have an action and I want to call redirect() something like:
$this->redirect('foo/search?Search[last_name]='.$this->form->getValue('last_name'));
Which should redirect to my Search action, and the form in that action should get the last_name parameter filled in. That action has code like so:
public function executeSearch(sfWebRequest $request)
{
$this->form = new SearchForm();
$submission = $request->getParameter($this->form->getName());
...do stuff with $submission...
The SearchForm has the name format 'Search[%s]'.
Nothing I've tried for the parameter to redirect() has worked. The Search[] parameters always get messed up in some way and will not populate the form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会尝试让 Symfony 根据路由和参数为您生成 URL:
参数数组应采用以下格式...
...因此 URL 将它们视为:
然后您应该能够使用.. ...
甚至可能...
希望对您有帮助或至少给您一些想法。
I would try to get Symfony to generate the URL for you based on the route and parameters:
The array of parameters should take the following format...
... so the URL takes them as:
You should then be able to use...
... and probably even...
Hope that helps or at least gives you some ideas.
尝试此解决方案。
另一种方法是将提交数据存储在用户会话中。
Try this solution.
Another method is to store submission data in user session.