I want to customize form rendering in symfony. I checked the docs and found out that you can set a theme for rendering with the {{ form_theme }} tag. This works fine if there is only one form at a time, but if you have multiple forms in the same template, this does not work.
A simple example from my index.html.twig
{% extends 'base.html.twig' %} {% block body %} <h1>Hello Form 1</h1> {% form_theme form1 'bootstrap_3_layout.html.twig' %} {{ form_start( form1 ) }} {{ form_end( form1 ) }} <h1>Hello Form 2</h1> {% form_theme form2 'bootstrap_3_horizontal_layout.html.twig' %} {{ form_start( form2 ) }} {{ form_end( form2 ) }} {% endblock %}
As you can see, there are two form variables, and I want form1 to form1 displayed using 'bootstrap_3_layout.html.twig' and form2 using 'bootstrap_3_horizontal_layout.html.twig' . I do not know the internal elements of Twig, but I think that themes override their block definitions.
The result is as follows

So my questions are: how can I visualize forms with given themes without interfering with each other. Is there a way to render the form in a separate clean process?
I tried the Twig extension with a custom function, but it seems the function uses the same Twig_Environment. I also tried a sub request with {% render}%, but that also does not work.
source share