Skip to content

Commit e00013d

Browse files
committed
minor #11021 [Form] Mention that form_theme _self only works with template inheritance (javiereguiluz)
This PR was merged into the 4.2 branch. Discussion ---------- [Form] Mention that form_theme _self only works with template inheritance I was going to fix #5475, but I realized it was already fixed for 3.4. However, when I reworded the form theme docs, I forgot to mention this, so this PR fixes this issue. Commits ------- e219675 [Form] Mention that form_theme _self only works with template inheritance
2 parents 89bc2db + e219675 commit e00013d

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)