如何在树枝中渲染CSRF输入? [英] How to render CSRF input in twig?

查看:87
本文介绍了如何在树枝中渲染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输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆