How to make form_rest() not display a field with Symfony2? How to make form_rest() not display a field with Symfony2? symfony symfony

How to make form_rest() not display a field with Symfony2?


Another option is to explicitly mark the field as rendered:

{% do form.contenu.setRendered %}


Another in my opinion less hacky way to do it is this:

{{ form_widget(form._token) }} // render the CSRF Token{{ form_end(form, {'render_rest': false}) }} // do not render anything else

It's from the official documentation (v3.0) so it's pretty much best practise i guess.


{{ form_rest(form) }} goes at the very end, after rendering each field "manually". If you are using it for the CSRF token you can always render it with:

{# Token CSRF #}{{ form_widget(form._token) }}