File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ you need is this JavaScript code:
149
149
// add-collection-widget.js
150
150
jQuery (document ).ready (function () {
151
151
jQuery (' .add-another-collection-widget' ).click (function (e ) {
152
- var list = jQuery (jQuery (this ).attr (' data-list' ));
152
+ var list = jQuery (jQuery (this ).attr (' data-list-selector ' ));
153
153
// Try to find the counter of the list or use the length of the list
154
154
var counter = list .data (' widget-counter' ) | list .children ().length ;
155
155
@@ -180,7 +180,8 @@ And update the template as follows:
180
180
{# store the prototype on the data-prototype attribute #}
181
181
<ul id="email-fields-list"
182
182
data-prototype="{{ form_widget(form.emails.vars.prototype)|e }}"
183
- data-widget-tags="{{ '<li></li>'|e }}">
183
+ data-widget-tags="{{ '<li></li>'|e }}"
184
+ data-widget-counter="{{ form.children|length }}">
184
185
{% for emailField in form.emails %}
185
186
<li>
186
187
{{ form_errors(emailField) }}
@@ -191,7 +192,7 @@ And update the template as follows:
191
192
192
193
<button type="button"
193
194
class="add-another-collection-widget"
194
- data-list="#email-fields-list">Add another email</button>
195
+ data-list-selector ="#email-fields-list">Add another email</button>
195
196
196
197
{# ... #}
197
198
{{ form_end(form) }}
You can’t perform that action at this time.
0 commit comments