Symfony 教义管理生成器列表过滤器获取没有 csrf 令牌的方法
编辑: 解决方案是这样的:
public function executeIndex(sfWebRequest $request)
{
if ($request->getParameter('first_name')) {
$this->setFilters(array('first_name' => $request->getParameter('first_name')));
}
parent::executeIndex($request);
}
嗨,
所以,我刚刚开始使用 symfony 管理生成器,它很棒。但是,我想知道如何使用 GET 请求过滤列表?例如 /users?name=Simon
如果我尝试: /users/filter/action/users[name]/Simon
它抱怨没有 CSRF 令牌,因为通常您使用它为您生成的过滤器表单进行过滤。
我想做的就是创建从一个列表到另一个列表的链接。例如,单击每个用户列表记录中的“查看此用户的帖子”会将您带到帖子屏幕,但该屏幕已被该用户过滤。
如果这实际上可以由generator.yml 完成,我不会感到惊讶,但我还不知道如何做到。
预先感谢您可以提供的任何帮助。
EDIT: The solution turned out to be along these lines:
public function executeIndex(sfWebRequest $request)
{
if ($request->getParameter('first_name')) {
$this->setFilters(array('first_name' => $request->getParameter('first_name')));
}
parent::executeIndex($request);
}
Hi,
So, I've just started using symfony admin generator and it's great. But, I want to know, how I can I filter the lists using a GET request? e.g. /users?name=Simon
If I try: /users/filter/action/users[name]/Simon
It complains there is no CSRF token, because usually you filter by using the filter form it generates for you.
All I want to do is create links from one list to the other. e.g. clicking "See this User's Posts" in each user list record will send you to the Posts screen but with it filtered by this user.
I wouldn't be surprised if this could actually be done by the generator.yml but I don't know how, yet.
Thanks in advance for any assistance you can provide.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里的回答解释了您需要什么: symfony - 可访问管理模块过滤器作为链接
My answer here explains what you need: symfony - admin module filters accessible as links
我尝试在主表中嵌入“目标”表的过滤器形式,您希望从中重定向隐藏除过滤器按钮之外的所有内容。正如您所提到的,如果没有令牌,它并不总是有效。
I have tried embedding the filter form of the "target" table in the main table from which you would like to be redirected hidding everything but the filter button. As you have mentioned it does not always work without the token.