phiamo / MopaBootstrapBundle

Easy integration of twitters bootstrap into symfony2
http://bootstrap.mohrenweiserpartner.de
711 stars 349 forks source link

Sections in forms #1238

Open vialcollet opened 6 years ago

vialcollet commented 6 years ago

Hi is it possible to setup sections in forms (other than tabs)? I didn't see any option in the doc. One solution would be to assign a specific call to the first field of a section but I don't know how to assign it to the form-group div rather than to the input itself. Ideas are welcome. Thanks!

isometriks commented 6 years ago

You can add a form as a child:

$subform = $builder->create('form');
$subform->add('field1', ...);
$subform->add('field2', ...);

$builder->add($subform)

And add any classes you might want. Really this is probably better solved in your view than in your forms, once you start doing stuff like this you'll have to structure your data differently to fit into sub arrays unless you use inherit_data.