Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[TwigBridge] Bootstrap Layout - Checkboxes and radios cannot be inline. #14704

Closed
@qferr

Description

@qferr

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions