I am new in Symfony2 and try to render a form. The basics are clear, but I have a problem with hidden form fields.
I try to render each form widget in a different table cell. But when using a for loop, the first cell is filled with the _token widget. But I like to render the hidden fields afterwards with form_rest.
<table>
<tr>
{% for element in form %}
<td class="header">{{ form_widget(element) }} </td>
{% endfor %}
</tr>
</table>
What I am looking for is something like
<table>
<tr>
{% for element in form %}
{% if element.type != 'hidden' %}
<td class="header">{{ form_widget(element) }} </td>
{% endif %}
{% endfor %}
</tr>
</table>
Can anyone help me with that? Thanks a lot.
Try this below code
Hope this helps you.
Happy coding!!!