Skip to content

Instantly share code, notes, and snippets.

@hpatoio
Created October 1, 2012 12:42
Show Gist options
  • Save hpatoio/3811437 to your computer and use it in GitHub Desktop.
Save hpatoio/3811437 to your computer and use it in GitHub Desktop.
Custom Twig template for embedded form.
{% block collection_widget %}
{% spaceless %}
{#
Inspired by:
https://groups.google.com/forum/?fromgroups=#!topic/symfony2/onor9uFte9E
https://gist.github.com/1294186
#}
{% if prototype is defined %}
{% set attr = attr|merge({'data-prototype': form_row(prototype) }) %}
{% endif %}
<div {{ block('widget_container_attributes') }}>
{% set fieldNum = 1 %}
{% for child in form %}
<div id="{{ id }}_{{ fieldNum }}">
<img src="{{ child.vars.value.slug }}.{{ child.vars.value.fileextension }}" />
{{ form_widget(child.name) }}
</div>
{% set fieldNum = fieldNum + 1 %}
{% endfor %}
</div>
{% endspaceless %}
{% endblock collection_widget %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment