Skip to content

Commit f5c6876

Browse files
author
daFish
committed
Added reusing of prototype template for displaying items from collection.
1 parent 931715a commit f5c6876

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cookbook/form/form_collections.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,13 @@ But if you are in the situation were you need to have a complete custom prototyp
743743

744744
.. code-block:: html+jinja
745745
data-prototype="{% filter escape %}{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' with { 'form': form.task.get('prototype') } %}{% endfilter %}"
746+
747+
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
748+
also use this markup to render the contents of the collection when it already holds items:
749+
750+
.. code-block:: html+jinja
751+
{% for task in tasks %}
752+
{% include 'AcmeTaskBundle:Task:prototypeTask.html.twig' with { 'form': form.task.vars.form } %}
753+
{% endfor %}
754+
755+
This makes sure the displayed items are the same as the newly inserted from the prototype.

0 commit comments

Comments
 (0)