You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cookbook/form/form_collections.rst
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -805,8 +805,18 @@ from the prototype.
805
805
806
806
But if you are in the situation were you need to have a complete custom prototype you can render it yourself:
807
807
808
-
.. code-block:: html+jinja
809
-
data-prototype="{% filter escape %}{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' with { 'form': form.task.get('prototype') } %}{% endfilter %}"
808
+
.. code-block:: html+jinja
809
+
data-prototype="{% filter escape %}{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' with { 'form': form.task.get('prototype') } %}{% endfilter %}"
810
+
811
+
The included `AcmeTaskBundle:Task:prototypeTask.html.twig` contains the markup used for the prototype. This way you can not only easily structure your prototype-markup, you can
812
+
also use this markup to render the contents of the collection when it already holds items:
813
+
814
+
.. code-block:: html+jinja
815
+
{% for task in tasks %}
816
+
{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' with { 'form': form.task.vars.form } %}
817
+
{% endfor %}
818
+
819
+
This makes sure the displayed items are the same as the newly inserted from the prototype.
810
820
811
821
.. _`Owning Side and Inverse Side`: http://docs.doctrine-project.org/en/latest/reference/unitofwork-associations.html
0 commit comments