Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1d50a13

Browse filesBrowse files
committed
synchronize code example with 4.3 branch
1 parent 9e4874a commit 1d50a13
Copy full SHA for 1d50a13

File tree

Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-3
lines changed

‎reference/forms/types/collection.rst

Copy file name to clipboardExpand all lines: reference/forms/types/collection.rst
+4-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.