Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form theme that only applies to templates in a particular bundle

Tags:

forms

symfony

How I can set form theme for bundle? In documentation is an example

twig:
    form:
        resources:
            - 'AcmeTaskBundle:Form:form_div_layout.html.twig'

But this form theming to each form in application. If use

{% form_theme form 'AcmeTaskBundle:Form:fields.html.twig' %}

Uncomfortable, because you need write for each form in application.

For example I have 2 main layout and 2 bundle (backend and frontend) and want form theming for each of this bundles. How I can do this? Any ideas?

like image 342
rtyshyk Avatar asked Feb 02 '12 11:02

rtyshyk


1 Answers

I think you can use template inheritance.

Put you form_theme call in one of your base layout and every template that inherits from it will use the good form theme.

UPDATE: This may not be possible because you dan't have any reference to the FormView actaully used.

like image 196
Florian Klein Avatar answered Oct 30 '22 19:10

Florian Klein