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 17a7e85

Browse filesBrowse files
committed
Merge branch '5.3' into 5.4
* 5.3: docs: Fix form collection example
2 parents ca41c88 + d410b3c commit 17a7e85
Copy full SHA for 17a7e85

File tree

1 file changed

+4
-4
lines changed
Filter options

1 file changed

+4
-4
lines changed

‎form/form_collections.rst

Copy file name to clipboardExpand all lines: form/form_collections.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ the following ``data-prototype`` attribute to the existing ``<ul>`` in your temp
243243

244244
.. code-block:: html+twig
245245

246-
<ul class="tags" data-prototype="{{ form_widget(form.tags.vars.prototype)|e('html_attr') }}"></ul>
246+
<ul class="tags" data-index="{{ form.tags|length > 0 ? form.tags|last.vars.name + 1 : 0 }}" data-prototype="{{ form_widget(form.tags.vars.prototype)|e('html_attr') }}"></ul>
247247

248248
Now add a button just next to the ``<ul>`` to dynamically add a new tag:
249249

@@ -255,7 +255,7 @@ On the rendered page, the result will look something like this:
255255

256256
.. code-block:: html
257257

258-
<ul class="tags" data-index="{{ form.tags|length > 0 ? form.tags|last.vars.name + 1 : 0 }}" data-prototype="&lt;div&gt;&lt;label class=&quot; required&quot;&gt;__name__&lt;/label&gt;&lt;div id=&quot;task_tags___name__&quot;&gt;&lt;div&gt;&lt;label for=&quot;task_tags___name___name&quot; class=&quot; required&quot;&gt;Name&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;task_tags___name___name&quot; name=&quot;task[tags][__name__][name]&quot; required=&quot;required&quot; maxlength=&quot;255&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;">
258+
<ul class="tags" data-index="0" data-prototype="&lt;div&gt;&lt;label class=&quot; required&quot;&gt;__name__&lt;/label&gt;&lt;div id=&quot;task_tags___name__&quot;&gt;&lt;div&gt;&lt;label for=&quot;task_tags___name___name&quot; class=&quot; required&quot;&gt;Name&lt;/label&gt;&lt;input type=&quot;text&quot; id=&quot;task_tags___name___name&quot; name=&quot;task[tags][__name__][name]&quot; required=&quot;required&quot; maxlength=&quot;255&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;">
259259

260260
.. seealso::
261261

@@ -537,7 +537,7 @@ First, add a "delete this tag" link to each tag form:
537537
})
538538
539539
// ... the rest of the block from above
540-
540+
541541
function addFormToCollection() {
542542
// ...
543543
@@ -553,7 +553,7 @@ The ``addTagFormDeleteLink()`` function will look something like this:
553553
const removeFormButton = document.createElement('button')
554554
removeFormButton.classList
555555
removeFormButton.innerText = 'Delete this tag'
556-
556+
557557
tagFormLi.append(removeFormButton);
558558
559559
removeFormButton.addEventListener('click', (e) => {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.