I recently started using Symfony2 framework.
I already apologize for any incorrect terminology I will be using.
I would like to customize how forms are presented in my application.
More specifically, in my Twig file I am rendering the entire form with
{{ form(forms) }}
I would like to customize the layout of the form. I know that each row of the form can be expanded as
{{ form_start(forms) }}
//...
<div>
{{ form_label(forms.field) }}
{{ form_errors(forms.field) }}
{{ form_widget(forms.field) }}
</div>
//...
{{ form_end(forms) }}
With the form written in this format I could add the needed customization to the layout.
Here is the problem: my form does not have a pre-defined number of rows, but these depend on some values stored in the database. What I would like to do in my Twig is something like this
{{ form_start(forms) }}
{% for field in forms %}
<div>
{{ form_label(forms.field) }}
{{ form_errors(forms.field) }}
{{ form_widget(forms.field) }}
</div>
{% endfor %}
{{ form_end(forms) }}
Unfortunately, this for loop does not work. I also looked into (How to Customize Form Rendering), but I think this does not suit my case (does it?).
Any suggestion?
Thank you in advance for your help.