From 6fb183aed28430cae8fd4309674ae63612982057 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 31 Mar 2020 16:16:20 +0200 Subject: [PATCH] Rephrasing the "If you render your whole" note (2nd attempt) Re-submitting https://github.com/symfony/symfony-docs/pull/13449 to fix conflict --- form/form_collections.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/form/form_collections.rst b/form/form_collections.rst index 2067197d950..0451a5dd5e2 100644 --- a/form/form_collections.rst +++ b/form/form_collections.rst @@ -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 @@ -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