-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fixed documentation of collection prototype #1486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fe0700f
d55a48d
cd3bd22
bc2feb7
934de43
9946be8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,13 +311,13 @@ new "tag" forms. To render it, make the following change to your template: | |
|
||
.. code-block:: html+jinja | ||
|
||
<ul class="tags" data-prototype="{{ form_widget(form.tags.getVar('prototype')) | e }}"> | ||
<ul class="tags" data-prototype="{{ form_widget(form.tags.vars.prototype) | e }}"> | ||
... | ||
</ul> | ||
|
||
.. code-block:: html+php | ||
|
||
<ul class="tags" data-prototype="<?php echo $view->escape($view['form']->row($form['tags']->getVar('prototype'))) ?>"> | ||
<ul class="tags" data-prototype="<?php echo $view->escape($view['form']->row($form['tags']->vars['prototype'])) ?>"> | ||
... | ||
</ul> | ||
|
||
|
@@ -329,18 +329,18 @@ new "tag" forms. To render it, make the following change to your template: | |
|
||
.. tip:: | ||
|
||
The ``form.tags.getVar('prototype')`` is form element that looks and feels just | ||
The ``form.tags.vars.prototype`` is form element that looks and feels just | ||
like the individual ``form_widget(tag)`` elements inside our ``for`` loop. | ||
This means that you can call ``form_widget``, ``form_row``, or ``form_label`` | ||
on it. You could even choose to render only one of its fields (e.g. the | ||
``name`` field): | ||
|
||
.. code-block:: html+jinja | ||
|
||
{{ form_widget(form.tags.getVar('prototype').name) | e }} | ||
{{ form_widget(form.tags.vars.prototype.name) | e }} | ||
|
||
.. versionadded:: 2.1 | ||
Prototype is accessed as ``form.tags.getVar('prototype')`` instead of ``form.tags.get('prototype')`` in Symfony 2.1 | ||
Prototype is accessed as ``form.tags.vars.prototype`` instead of ``form.tags.get('prototype')`` in Symfony 2.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it already works in 2.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but we should update the 2.0 doc to show the same so people start writing it like this already. What do you think ? |
||
|
||
|
||
On the rendered page, the result will look something like this: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,7 @@ you need is the JavaScript: | |
{# ... #} | ||
|
||
{# store the prototype on the data-prototype attribute #} | ||
<ul id="email-fields-list" data-prototype="{{ form_widget(form.emails.getVar('prototype')) | e }}"> | ||
<ul id="email-fields-list" data-prototype="{{ form_widget(form.emails.vars.prototype) | e }}"> | ||
{% for emailField in form.emails %} | ||
<li> | ||
{{ form_errors(emailField) }} | ||
|
@@ -295,11 +295,11 @@ collection field: | |
|
||
.. code-block:: jinja | ||
|
||
{{ form_row(form.emails.getVar('prototype')) }} | ||
{{ form_row(form.emails.vars.prototype) }} | ||
|
||
.. code-block:: php | ||
|
||
<?php echo $view['form']->row($form['emails']->getVar('prototype')) ?> | ||
<?php echo $view['form']->row($form['emails']->vars['prototype']) ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same issue here for the PHP template |
||
|
||
Note that all you really need is the "widget", but depending on how you're | ||
rendering your form, having the entire "form row" may be easier for you. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong. For the PHP template, you should document
getVar()
. If you want to use the same way than Twig, it would be->getVars()['prototype']
, but this only wokrs on PHP 5.4 with the array dereferencingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm sorry about that. It was maybe a little too late when I did this…