Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b0213b

Browse filesBrowse files
committed
Added a note about customizing a form with more than one template
1 parent 9f26da8 commit 2b0213b
Copy full SHA for 2b0213b

File tree

Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+27
-0
lines changed

‎cookbook/form/form_customization.rst

Copy file name to clipboardExpand all lines: cookbook/form/form_customization.rst
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,33 @@ When the ``form.age`` widget is rendered, Symfony will use the ``integer_widget`
298298
block from the new template and the ``input`` tag will be wrapped in the
299299
``div`` element specified in the customized block.
300300

301+
Multiple templates
302+
..................
303+
304+
A form can also be customized applying several templates. To do so, pass the
305+
name of all the templates to the ``form_theme`` tag separating them with one
306+
whitespace:
307+
308+
.. code-block:: html+jinja
309+
310+
{% form_theme form '::common.html.twig' ':Form:fields.html.twig'
311+
'AcmeDemoBundle:Form:fields.html.twig' %}
312+
313+
{# ... #}
314+
315+
The templates can be located at different bundles and they can even be stored
316+
at the global ``app/Resources/views/`` directory.
317+
318+
When using the ``with`` keyword, pass the templates as an array:
319+
320+
321+
.. code-block:: html+jinja
322+
323+
{% form_theme form with ['::common.html.twig', ':Form:fields.html.twig',
324+
'AcmeDemoBundle:Form:fields.html.twig'] %}
325+
326+
{# ... #}
327+
301328
Child Forms
302329
...........
303330

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.