I have a dynamic form to create and i want to extend a widget in order to display it as <tr>
.
The fact is that each column of the table is a dynamic group containing some fields.
All I want to do is iterate over groups in the myform_widget
like that :
Here is the table header
<table id="myforms-table" class="table">
<thead>
<tr>
{% for group in groups %}<th>{{ group.label }}</th>{% endfor %}
</tr>
</thead>
<tbody data-prototype="{{ form_widget(form.myforms.vars.prototype)|e }}">
</tbody>
</table>
Here is the myform block :
{% block myform_widget %}
<tr>
{% for group in groups %}
<td>
{% for field in group.fields %}
{{ form_row( form.children.(field.codeField) ) }}
{% endfor %}
</td>
{% endfor %}
</tr>
{% endblock %}
And I get an exception Variable "groups" does not exist
.
I assume that the form_theme cannot access to groups
variable, but how can I have access to it ?
strong text
Thanks o/
I have found a simple solution.
In my form type file I've added a
groups
attr, like that :Now I'm able to retrieve it with :