Reputation: 4117
I want to create forms in symfony2. I need this HTML structur for each control.
<div class="form-group">
<label class="col-md-2 control-label">Firstname:</label>
<div class="col-md-10"><input type="text" name="firstname" class="form-control">/div>
</div>
Now is my question, how can i add the div with the class form-group
and how can i surround the input element with the div .col-md-10
?
$builder->add('firstname', 'text', array(
'attr' => array(
'class' => 'form-control'),
'label_attr' => array(
'class' => 'col-md-2 control-label'
)
)
);
Upvotes: 2
Views: 71
Reputation: 13891
Check How to customize Form Rendering section of the documentation.
You may need to override the form_widget
block (form_widget_compound
block to go into details).
Find here the default behavior of each twig form helper.
The Form Theming Sub Chapter contains many relevant examples on how to customize any given form field block.
Upvotes: 2