Reputation: 936
I am working on a form quite complicated.
This form is based on an OngletFichier
Entity
with its form Builder :
$builder
->add('traitement')
->add('ligneEntetes');
$builder->add('colonnesOnglet', 'collection', array('type' => new ColonneOngletType()
));
As you can see, in this Entity Form, I got a list of ColonneOnglet
which is an other entity.
It looks like something like that :
Entity Form
OngletFichier
(text input)OngletFichier
(text input)ColonneOnglet
(which have its own attributes, its own input)ColonneOnglet
(which have its own attributes, its own input)ColonneOnglet
(which have its own attributes, its own input)I need to define a special form theme for each ColonneOnglet
to organize its inputs, and to put it in red or not depending on one of its attribute.
I am quite lost with form theming.
I found an example but I don't know if it can answer my problem : http://symfony2-document.readthedocs.org/en/latest/cookbook/form/create_custom_field_type.html
Thanks in advance for helping me !
EDIT : http://symfony.com/doc/current/cookbook/form/form_customization.html#how-to-customize-an-individual-field This works easily !
Upvotes: 0
Views: 949
Reputation: 745
The article you've found is good, but I think this section of the manual fits better: http://symfony.com/doc/2.0/cookbook/form/form_customization.html#how-to-customize-an-individual-field
So the easiest way is to create separate file with form theme and import it into template using
form_theme form 'Path:To:theme.html.twig'
. You can also define your styling inside the template itself and import using this directive: form_theme form _self
, but be aware that in order for this to work the template must extend another one.
Upvotes: 1