Skip to content

Commit e219675

Browse files
committed
[Form] Mention that form_theme _self only works with template inheritance
1 parent 89bc2db commit e219675

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

form/form_themes.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ for any overridden form blocks:
341341

342342
.. code-block:: html+twig
343343

344+
{% extends 'base.html.twig' %}
345+
344346
{% form_theme form _self %}
345347

346348
{# this overrides the widget of any field of type integer, but only in the
@@ -359,12 +361,16 @@ for any overridden form blocks:
359361
</div>
360362
{% endblock %}
361363

362-
363364
{# ... render the form ... #}
364365

365-
The disadvantage of this method is that the customized form blocks can't be
366-
reused when rendering other forms in other templates. If that's what you need,
367-
create a form theme in a separate template as explained in the next section.
366+
The main disadvantage of this method is that it only works if your template
367+
extends another (``'base.html.twig'`` in the previous example). If your template
368+
does not, you must point ``form_theme`` to a separate template, as explained in
369+
the next section.
370+
371+
Another disadvantage is that the customized form blocks can't be reused when
372+
rendering other forms in other templates. If that's what you need, create a form
373+
theme in a separate template as explained in the next section.
368374

369375
Creating a Form Theme in a Separate Template
370376
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)