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:
145
145
// add-collection-widget.js
146
146
jQuery (document ).ready (function () {
147
147
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 ' ));
149
149
// Try to find the counter of the list or use the length of the list
150
150
var counter = list .data (' widget-counter' ) || list .children ().length ;
151
151
@@ -176,7 +176,8 @@ And update the template as follows:
176
176
{# store the prototype on the data-prototype attribute #}
177
177
<ul id="email-fields-list"
178
178
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 }}">
180
181
{% for emailField in form.emails %}
181
182
<li>
182
183
{{ form_errors(emailField) }}
@@ -187,7 +188,7 @@ And update the template as follows:
187
188
188
189
<button type="button"
189
190
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>
191
192
192
193
{# ... #}
193
194
{{ form_end(form) }}
You can’t perform that action at this time.
0 commit comments