-
-
Save eikes/5788231 to your computer and use it in GitHub Desktop.
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 %} | |
<div class="collection"> | |
{% if prototype is defined %} | |
{% set attr = attr|merge({'data-prototype': block('collection_item_widget') }) %} | |
{% endif %} | |
<div {{ block('widget_container_attributes') }}> | |
{{ form_errors(form) }} | |
<ul> | |
{% for prototype in form %} | |
block('collection_item_widget') | |
{% endfor %} | |
</ul> | |
{{ form_rest(form) }} | |
</div> | |
<div class="clear"></div> | |
<a class="add" title="Add" href="javascript:void()"> | |
<div style="display: none;"></div> | |
<span>Add</span> | |
</a> | |
</div> | |
<div class="clear"></div> | |
{% endspaceless %} | |
{% endblock collection_widget %} | |
{% block collection_item_widget %} | |
{% spaceless %} | |
<li> | |
{% set fieldNum = 1 %} | |
{% for row in prototype %} | |
<div class="field{{ fieldNum }}"> | |
{{ form_label(row) }} | |
{{ form_widget(row, { 'attr': { 'class': 'test' }}) }} | |
</div> | |
{% set fieldNum = fieldNum + 1 %} | |
{% endfor %} | |
<a class="remove" title="Remove" href="javascript:void()"> | |
<span>Delete</span> | |
</a> | |
<div class="clear"></div> | |
</li> | |
{% endspaceless %} | |
{% endblock collection_item_widget %} |
I am trying to use collection widget for tag collection in one of the Task/Tag tutorial of Symfony. I am trying to use this in below form for tag collection. I am new to Symfony, and having difficulties getting hold of theme customization. Can you please help me how can I use collection_widget in example form below. Thank You.
<\form action="{{ path('TaskBundle_task') }}" method="POST" {{ form_enctype(form) }}>
{{ form_row(form.title) }}
{{ form_row(form.description) }}
<\h3>Tags</h3>
<ul class="tags" id="tags" data-prototype="{{ form_widget(form.tags.vars.prototype)|e }}">
{% for tag in form.tags %}
<li>{{ form_row(tag.name) }} </li>
{% endfor %}
</ul>
{{ form_rest(form) }}
<\input type="submit" value="Submit" />
</form>
Do I need to define javascript:void()
. What does it stands for?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, thx for this !
just to note you have a small typo line 11 :
should be :