8000 [Form] Document disabling the usage of globally defined form themes by emodric · Pull Request #8495 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

[Form] Document disabling the usage of globally defined form themes #8495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions form/form_customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,38 @@ name of all the templates as an array using the ``with`` keyword:
The templates can also be located in different bundles, use the Twig namespaced
path to reference these templates, e.g. ``@AcmeFormExtra/form/fields.html.twig``.

Disabling usage of globally defined themes
..........................................

Sometimes it is useful to disable usage of globally defined form themes in order
to have more control over rendering of a form. You might want this, for example,
when creating admin interface for a bundle which can be installed on a wide range
of Symfony apps and you can't control what themes are defined globally.

You can do this by including the ``only`` keyword after the list of used form
themes:

.. code-block:: html+twig

{% form_theme form with ['common.html.twig', 'form/fields.html.twig'] only %}

{# ... #}

.. caution::

When using the ``only`` keyword, none of Symfony's built-in form themes
(``form_div_layout.html.twig``, etc.) will be applied. In order to render
your forms correctly, you need to either provide a full-featured form theme
yourself, or extend one of the built-in form themes with Twig's ``use``
keyword instead of ``extends`` to reuse the original theme contents.

.. code-block:: html+twig

{# app/Resources/views/common.html.twig #}
{% use "form_div_layout.html.twig" %}

{# ... #}

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

Expand Down
0