Skip to content

[TwigBridge] label_attr not work #44332

@123ValentinM

Description

@123ValentinM

Symfony version(s) affected

5.3.11

Description

Hi everebody.

Since symfony version 5.3.11 and more specifically twig-bridge version 5.3.11 https://github.com/symfony/twig-bridge/releases/tag/v5.3.11 the label_attr of my symfony form no longer works.

If I go back to twig-bridge 5.3.7 it works normally.

My symfony code :


->add('type', ChoiceType::class, [

                'choices' => array(
                    "choice1" => 8,
                    "choice2" => 4,
                    "choice3" => 9,
                ),
                'attr' => [ 'class' => 'd-flex justify-content-between flex-wrap  custom-control custom-radio  pl-0 ml-2  mt-0 mt-lg-4'],
                // Label
                'choice_label' => function ($choice, $key, $value) {
                    return ucfirst($key);
                },
                "label_attr" => ["class" => "custom-control-label pl-1 mb-4 mr-3"],
                // Input
                'choice_attr' => function ($choice, $key, $value) {
                    return ['class' => 'custom-control-input'];
                },

                'data' => 8, 
                'label' => false, 
                'multiple' => false, 
                'expanded' => true 
            ]

My Twig code :

{{ form_widget(form.type) }}

How to reproduce

Use bootstrap 4 form theme with symfony form ChoiceType and twig-bridge 5.3.11.

Possible Solution

I think the code for version 5.3.11 fixes some problem but apparently it creates more, or am I doing something wrong ?

Additional Context

Thank for the help !

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