Created
August 24, 2013 09:02
-
-
Save tentacode/6327011 to your computer and use it in GitHub Desktop.
Separating regular fields and buttons rendering in a Symfony/Twig form. (from Symfony 2.3)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro form_fields(form) %} | |
{% for field in form %} | |
{% if field.vars.block_prefixes[0] != 'button' %} | |
{{ form_row(field) }} | |
{% endif %} | |
{% endfor %} | |
{% endmacro %} | |
{% import _self as macros %} | |
<form class="form-horizontal" method="post" action="{{ path('foo_bar') }}" {{ form_enctype(form) }}> | |
{{ macros.form_fields(form) }} | |
<div class="form-actions"> | |
<p> | |
{{ form_widget(form.submit) }} | |
</p> | |
</div> | |
{{ form_rest(form) }} | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment