Skip to content

[TwigBridge] label class incorrectly applied to expanded choice field #40005

Closed
@aurelijusrozenas

Description

@aurelijusrozenas

Symfony version(s) affected: Symfony 4.4, but it seems to be the same on 5.* also.

Description
Seems to be a bug for some of the form templates for choice field with expanded and multiple settings set to true.

What I want is to add css class to label of choice class but not the choices. I add 'label_attr' => ['class' => 'red'] as I would to any field. And it actualy works if I set expanded to false.

It seems all bootstrap templates suffer from same problem but not div and table templates.

It this a bug in bootstrap templates?

image

ChoiceType::class,
[
    'choices' => ['choice must be black' => 'test'],
    'label' => 'label must be red because of css class',
    'label_attr' => ['class' => 'red'],
    'multiple' => true,
    'expanded' => true,
]

How to reproduce

git clone https://github.com/aurelijusrozenas/sf-form-choice-template-bug.git
cd sf-form-choice-template-bug
composer install
symfony serve

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