Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy