Closed
Description
It would be nice to have an option to add a class name here (Bootstrap theme):
https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig#L193
That is the <div>
around each radio button / checkbox.
Suggested name: choice_row_attr
- since choice_attr
addresses the <input>
, and row_attr
the <div>
containing all the radios.
So if you either do:
public function finishView(FormView $view, FormInterface $form, array $options)
{
$view['field'][0]->vars['choice_row_attr'] = ['class' => 'foo'];
}
... or ...
{% for key, field in form.field.children %}
{{ form_widget(field, {'choice_row_attr': {'class':'foo'}}) }}
{% endfor %}
...the outcome would be:
<div class="form-check foo">
<input type="radio" ...>
</div>
<div class="form-check foo">
<input type="radio" ...>
</div>
<div class="form-check foo">
<input type="radio" ...>
</div>
My use case:
I'm having a list of like 20 radio buttons, and depending on the user's selection in another field, some of them get hidden (with JavaScript).
Other use case would be to highlight some radios.