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 d410b3c

Browse filesBrowse files
committed
minor #15774 docs: Fix form collection example (chapterjason)
This PR was merged into the 5.3 branch. Discussion ---------- docs: Fix form collection example First reported here: symfony/symfony#42870 Not sure which branch, took the lowest one where this occurs. Commits ------- 85bbbed docs: Fix form collection example
2 parents ea9fa22 + 85bbbed commit d410b3c
Copy full SHA for d410b3c

File tree

Expand file treeCollapse file tree

1 file changed

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

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.