8000 Merge pull request #1129 from fixe/patch-1 · symfony/symfony-docs@46c80c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 46c80c2

Browse files
committed
Merge pull request #1129 from fixe/patch-1
Changed default name of the prototype from "$$name$$" to "__name__".
2 parents 53bbd5d + ba05ef7 commit 46c80c2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

reference/forms/types/collection.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ will look like this:
128128

129129
.. code-block:: html
130130

131-
<input type="email" id="form_emails_$$name$$" name="form[emails][$$name$$]" value="" />
131+
<input type="email" id="form_emails___name__" name="form[emails][__name__]" value="" />
132132

133-
By replacing ``$$name$$`` with some unique value (e.g. ``2``),
133+
By replacing ``__name__`` with some unique value (e.g. ``2``),
134134
you can build and insert new HTML fields into your form.
135135

136136
Using jQuery, a simple example might look like this. If you're rendering
@@ -171,10 +171,10 @@ you need is the JavaScript:
171171

172172
// grab the prototype template
173173
var newWidget = emailList.attr('data-prototype');
174-
// replace the "$$name$$" used in the id and name of the prototype
174+
// replace the "__name__" used in the id and name of the prototype
175175
// with a number that's unique to our emails
176176
// end name attribute looks like name="contact[emails][2]"
177-
newWidget = newWidget.replace(/\$\$name\$\$/g, emailCount);
177+
newWidget = newWidget.replace(/__name__/g, emailCount);
178178
emailCount++;
179179

180180
// create a new list element and add it to our list
@@ -284,8 +284,8 @@ This option is useful when using the `allow_add`_ option. If ``true`` (and
284284
if `allow_add`_ is also ``true``), a special "prototype" attribute will be
285285
available so that you can render a "template" example on your page of what
286286
a new element should look like. The ``name`` attribute given to this element
287-
is ``$$name$$``. This allows you to add a "add another" button via JavaScript
288-
which reads the prototype, replaces ``$$name$$`` with some unique name or
287+
is ``__name__``. This allows you to add a "add another" button via JavaScript
288+
which reads the prototype, replaces ``__name__`` with some unique name or
289289
number, and render it inside your form. When submitted, it will be added
290290
to your underlying array due to the `allow_add`_ option.
291291

0 commit comments

Comments
 (0)
0