Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4084a8d

Browse files
committed
[forms][collections] Changing how we access the prototype to be consistent with Symfony 2.1
Both the old and the new syntax work, but due to a BC break in 2.1, only the second is correct in 2.1. To add more consistency between the versions, we're documenting and recommending this change. This relates to symfony#1486
1 parent e552a55 commit 4084a8d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cookbook/form/form_collections.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ new "tag" forms. To render it, make the following change to your template:
307307

308308
.. code-block:: html+jinja
309309

310-
<ul class="tags" data-prototype="{{ form_widget(form.tags.get('prototype')) | e }}">
310+
<ul class="tags" data-prototype="{{ form_widget(form.tags.vars.prototype) | e }}">
311311
...
312312
</ul>
313313

@@ -325,15 +325,15 @@ new "tag" forms. To render it, make the following change to your template:
325325

326326
.. tip::
327327

328-
The ``form.tags.get('prototype')`` is form element that looks and feels just
328+
The ``form.tags.vars.prototype`` is form element that looks and feels just
329329
like the individual ``form_widget(tag)`` elements inside our ``for`` loop.
330330
This means that you can call ``form_widget``, ``form_row``, or ``form_label``
331331
on it. You could even choose to render only one of its fields (e.g. the
332332
``name`` field):
333333

334334
.. code-block:: html+jinja
335335

336-
{{ form_widget(form.tags.get('prototype').name) | e }}
336+
{{ form_widget(form.tags.vars.prototype.name) | e }}
337337

338338
On the rendered page, the result will look something like this:
339339

reference/forms/types/collection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ you need is the JavaScript:
146146
{# ... #}
147147

148148
{# store the prototype on the data-prototype attribute #}
149-
<ul id="email-fields-list" data-prototype="{{ form_widget(form.emails.get('prototype')) | e }}">
149+
<ul id="email-fields-list" data-prototype="{{ form_widget(form.emails.vars.prototype) | e }}">
150150
{% for emailField in form.emails %}
151151
<li>
152152
{{ form_errors(emailField) }}
@@ -295,7 +295,7 @@ collection field:
295295

296296
.. code-block:: jinja
297297
298-
{{ form_row(form.emails.get('prototype')) }}
298+
{{ form_row(form.emails.vars.prototype) }}
299299
300300
.. code-block:: php
301301

0 commit comments

Comments
 (0)