Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit17a7e85

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: docs: Fix form collection example
2 parentsca41c88 +d410b3c commit17a7e85

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎form/form_collections.rst‎

Lines 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 data-prototype="{{ form_widget(form.tags.vars.prototype)|e('html_attr') }}"></ul>
246+
<ul 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-
<ulclass="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+
<ulclass="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
functionaddFormToCollection() {
542542
// ...
543543
@@ -553,7 +553,7 @@ The ``addTagFormDeleteLink()`` function will look something like this:
553553
constremoveFormButton=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)

[8]ページ先頭

©2009-2025 Movatter.jp