Skip to content

Rephrasing the "If you render your whole" note (2nd attempt) #13460

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 1 commit into from
Apr 1, 2020
Merged
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
12 changes: 6 additions & 6 deletions form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,6 @@ On the rendered page, the result will look something like this:
If you want to customize the HTML code in the prototype, see
:ref:`form-custom-prototype`.

.. note::

If you render your whole "tags" sub-form at once (e.g. ``form_row(form.tags)``),
then the prototype is automatically available on the outer ``div`` as
the ``data-prototype`` attribute, similar to what you see above.

.. tip::

The ``form.tags.vars.prototype`` is a form element that looks and feels just
Expand All @@ -286,6 +280,12 @@ On the rendered page, the result will look something like this:

{{ form_widget(form.tags.vars.prototype.name)|e }}

.. note::

If you render your whole "tags" sub-form at once (e.g. ``form_row(form.tags)``),
the ``data-prototype`` attribute is automatically added to the containing ``div``,
and you need to adjust the following JavaScript accordingly.

The goal of this section will be to use JavaScript to read this attribute
and dynamically add new tag forms when the user clicks a "Add a tag" link.
To make things simple, this example uses jQuery and assumes you have it included
Expand Down