Search code examples
phpsymfonycsrftwig

How to render CSRF input in twig?


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.


Solution

  • you can do it with {{ form_widget(formView._token) }}