Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explicitly print CSRF token field instead of form_rest(form)?

Tags:

How can I explicitly print CSRF field instead of using {{ form_rest(form) }}?

I need this because I'm going to hide/show some fields based on conditions, however {{ form_rest(form) }} is going to print all of the remaining fields (which is what I'd like to avoid).

like image 391
Polmonino Avatar asked Mar 28 '12 10:03

Polmonino


1 Answers

It can be done this way:

{{ form_widget(form._token) }} 

Also you might want to consider adding fields conditionally in your form type instead of making that kind of decisions in a template.

like image 96
Elnur Abdurrakhimov Avatar answered Sep 28 '22 20:09

Elnur Abdurrakhimov