I want to Implement the following field in symfony2. It has 2 Radio Buttons, and they are styled like Switch using some bootstrap styling.
above html and bootstrap, snippet displays desired output
<div class="btn-group btn-toggle" data-toggle="buttons">
<label class="btn btn-primary active">
<input type="radio" name="options" value="option1"> On
</label>
<label class="btn btn-default">
<input type="radio" name="options" value="option2" checked=""> Off
</label>
</div>
which outputs
for this example to work it requires tag inside tag. but symfony form builder is rendering
<radio>..</radio>
<label></label>
how can I render <radio>
tag inside <label>
using symfony form builder?
In symfony for checkbox we use this code , but it displays normal radio group,
->add('check', 'choice', array(
'choices' => array(
0 => 'On',
1 => 'Off'
),
'expanded' => true,
'multiple' => false,
'data' => 1
))
Read this: http://symfony.com/doc/current/cookbook/form/form_customization.html
And look at this: https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig