File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ you need is this JavaScript code:
145145 // add-collection-widget.js
146146 jQuery (document ).ready (function () {
147147 jQuery (' .add-another-collection-widget' ).click (function (e ) {
148- var list = jQuery (jQuery (this ).attr (' data-list' ));
148+ var list = jQuery (jQuery (this ).attr (' data-list-selector ' ));
149149 // Try to find the counter of the list or use the length of the list
150150 var counter = list .data (' widget-counter' ) || list .children ().length ;
151151
@@ -176,7 +176,8 @@ And update the template as follows:
176176 {# store the prototype on the data-prototype attribute #}
177177 <ul id="email-fields-list"
178178 data-prototype="{{ form_widget(form.emails.vars.prototype)|e }}"
179- data-widget-tags="{{ '<li></li>'|e }}">
179+ data-widget-tags="{{ '<li></li>'|e }}"
180+ data-widget-counter="{{ form.emails|length }}">
180181 {% for emailField in form.emails %}
181182 <li>
182183 {{ form_errors(emailField) }}
@@ -187,7 +188,7 @@ And update the template as follows:
187188
188189 <button type="button"
189190 class="add-another-collection-widget"
190- data-list="#email-fields-list">Add another email</button>
191+ data-list-selector ="#email-fields-list">Add another email</button>
191192
192193 {# ... #}
193194 {{ form_end(form) }}
You can’t perform that action at this time.
0 commit comments