Created
October 17, 2011 18:25
-
-
Save cowlby/1293363 to your computer and use it in GitHub Desktop.
Customizing form collections in Symfony2
This file contains 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
{% block collection_widget %} | |
{% spaceless %} | |
{% if prototype is defined %} | |
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %} | |
{% endif %} | |
<div class="collection" {{ block('widget_container_attributes') }}> | |
{{ form_errors(form) }} | |
<table> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Value</th> | |
<th>Action</th> | |
</tr> | |
</thead> | |
<tbody> | |
{% for rows in form %} | |
block('collection_item_widget') | |
{% endfor %} | |
</tbody> | |
</table> | |
{{ form_rest(form) }} | |
<a class="collection_add btn" title="Add" href="#">Add</a> | |
</div> | |
{% endspaceless %} | |
{% endblock collection_widget %} | |
{% block collection_item_widget %} | |
{% spaceless %} | |
<tr> | |
{% for row in prototype %} | |
<td> | |
{{ form_widget(row) }} | |
</td> | |
{% endfor %} | |
<td> | |
<a class="remove" title="Remove" href="#">Delete</a> | |
</td> | |
</tr> | |
{% endspaceless %} | |
{% endblock collection_item_widget %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment