如何在树枝中呈现 CSRF 输入?树枝、如何在、CSRF

2023-09-07 00:09:51 作者:来不及说再见

我知道使用 form_rest 呈现 CSRF 令牌隐藏输入的常用方法,但是有没有办法呈现 just CSRF 输入本身?我在主题中覆盖了 {% block field_widget %} 以呈现一段额外的文本.但是由于 CSRF 令牌也在输入字段中呈现,并且我在隐藏字段旁边得到了一段我不需要的文本.所以我想用一个参数单独渲染它,告诉它不要渲染这个文本.

I know there's the usual way to render CSRF token hidden input with form_rest, but is there a way to render just CSRF input itself? I've overridden {% block field_widget %} in theme to render a piece of additional text. But as CSRF token is rendered in input field too and I got a piece of text I don't need next to a hidden field. So I'd like to render it separately with an argument that tells it not to render this text.

推荐答案

你可以用 {{ form_widget(formView._token) }}

 
精彩推荐
图片推荐