How to render CSRF input in twig?(如何在树枝中呈现 CSRF 输入?)
问题描述
我知道使用 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) }}
这篇关于如何在树枝中呈现 CSRF 输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在树枝中呈现 CSRF 输入?
基础教程推荐
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php中的PDF导出 2022-01-01
- php中的foreach复选框POST 2021-01-01
