Closed
Description
Hello,
Checkboxes and radios cannot be inline because the parent_label_class
is defined only in a form type choice
. See
Example:
...
$builder
->add('my_checkbox', 'checkbox', ['label_attr' => ['class' => 'checkbox-inline']])
->add('my_radio', 'radio', ['label_attr' => ['class' => 'checkbox-inline']])
->add('my_choice', 'choice', ['expanded' => true, 'label_attr' => ['class' => 'checkbox-inline']]);
...
...
{# It doesn't work #}
{{ form_widget(form.my_checkbox) }}
{{ form_widget(form.my_radio) }}
{# It works #}
{{ form_widget(form.my_choice) }}
...
I suggest a solution:
{% block checkbox_widget -%}
{# Currently #}
{% set parent_label_class = parent_label_class|default('') -%}
{# Fixed #}
{% set parent_label_class = label_attr.class|default('') -%}
...
{%- endblock checkbox_widget %}
{% block radio_widget -%}
{# Currently #}
{% set parent_label_class = parent_label_class|default('') -%}
{# Fixed #}
{% set parent_label_class = label_attr.class|default('') -%}
...
{%- endblock radio_widget %}
Thank you.