I have a simple question : Can we pass css class to options in form_builder ? I explain :
I have a field and I passed the $options
values like this
$builder
->add('motif', 'choice', array(
'choices' => $options['data']['myoptions'],
'multiple' => false,
'required' => true,
'expanded' => false,
));
On my template this code look like a simple select list like this
<select name="exempleselect">
<option value="1">value 1</option>
<option value="2">value 2</option>
<option value="3">value 3</option>
</select>
Can we pass css class to get my list like this ?
<select name="exempleselect">
<option class="value1" value="1">value 1</option>
<option class="value2" value="2">value 2</option>
<option class="value3" value="3">value 3</option>
</select>
Thanks
Try this:
$builder
->add('motif', 'choice', array(
'choices' => $options['data']['myoptions'],
'multiple' => false,
'required' => true,
'expanded' => false,
'attr' => array('class' => 'your class',
OR
'style' => 'width:100px; ...'
));