Skip to content

Commit 1d50a13

Browse files
committed
synchronize code example with 4.3 branch
1 parent 9e4874a commit 1d50a13

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

reference/forms/types/collection.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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) }}

0 commit comments

Comments
 (0)