Skip to content

Commit

Permalink
Added a note about customizing a form with more than one template
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed May 26, 2014
1 parent 9f26da8 commit 2b0213b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cookbook/form/form_customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,33 @@ When the ``form.age`` widget is rendered, Symfony will use the ``integer_widget`
block from the new template and the ``input`` tag will be wrapped in the
``div`` element specified in the customized block.

Multiple templates
..................

A form can also be customized applying several templates. To do so, pass the
name of all the templates to the ``form_theme`` tag separating them with one
whitespace:

.. code-block:: html+jinja

{% form_theme form '::common.html.twig' ':Form:fields.html.twig'
'AcmeDemoBundle:Form:fields.html.twig' %}

{# ... #}

The templates can be located at different bundles and they can even be stored
at the global ``app/Resources/views/`` directory.

When using the ``with`` keyword, pass the templates as an array:


.. code-block:: html+jinja

{% form_theme form with ['::common.html.twig', ':Form:fields.html.twig',
'AcmeDemoBundle:Form:fields.html.twig'] %}

{# ... #}

Child Forms
...........

Expand Down

0 comments on commit 2b0213b

Please sign in to comment.