Symfony2 - theme for several forms

Is there a way to use different themes for two (or more) forms on the same page. I have 2 forms and I would like to use the "X" theme for the first form and the "Y" theme for the second form.

+3
source share
1 answer

You need to declare your theme before displaying your form.

You must try:

{% form_theme form 'ThemeX.html.twig' %} {{ form(formX) }} {% form_theme form 'ThemeY.html.twig' %} {{ form(formY) }} 

If this does not work (that is, declaring a topic in the second form does not overwrite the first), simply use a separate template for your second form and insert it into the parent template using include.

Try the [ http://symfony.com/doc/current/cookbook/form/form_customization.html#child-forms 022(this page) symfony document for more information.

+3
source

Source: https://habr.com/ru/post/982009/


All Articles