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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With