Skip to content

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

Merged
merged 6 commits into from
Jul 3, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cookbook/form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.get('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']->get('prototype'))) ?>">
<ul class="tags" data-prototype="<?php echo $view->escape($view['form']->row($form['tags']->getVar('prototype'))) ?>">
...
</ul>

Expand All @@ -329,15 +329,16 @@ new "tag" forms. To render it, make the following change to your template:

.. tip::

The ``form.tags.get('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.get('prototype').name) | e }}
{{ form_widget(form.tags.vars.prototype.name) | e }}


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

Expand Down
6 changes: 3 additions & 3 deletions reference/forms/types/collection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.get('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) }}
Expand Down Expand Up @@ -295,11 +295,11 @@ collection field:

.. code-block:: jinja

{{ form_row(form.emails.get('prototype')) }}
{{ form_row(form.emails.vars.prototype) }}

.. code-block:: php

<?php echo $view['form']->row($form['emails']->get('prototype')) ?>
<?php echo $view['form']->row($form['emails']->getVar('prototype')) ?>

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.
Expand Down