symfony-forms Forms Check if all fields are rendered in the template


When rendering a form 'by hand', it can be useful to know if there are fields left to render or not. The function isRendered() from the FormView class returns true if there are still fields left to be rendered to the template.

This snippet prints <h3>Extra fields</h3> if there are fields left to be added to the template, followed by the fields themselves.

{% if not form.isRendered() %}
    <h3>Extra fields</h3>
    {{ form_rest(form) }}
{% endif %}