Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aurelijusrozenas opened this issue Jan 27, 2021 · 8 comments
Closed

Comments

@aurelijusrozenas
Copy link
Contributor

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
@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Friendly ping? Should this still be open? I will close if I don't hear anything.

@aurelijusrozenas
Copy link
Contributor Author

Yes, the bug is still present.

@seb-jean
Copy link
Contributor

I also reproduced the bug.

@fabpot
Copy link
Member

fabpot commented Aug 25, 2021

Anyone willing to investigate the issue and submit a PR?

@seb-jean
Copy link
Contributor

Related #18318

@xabbuh
Copy link
Member

xabbuh commented Sep 9, 2021

Can you then please check if the linked PR solves this?

@aurelijusrozenas
Copy link
Contributor Author

@xabbuh Yes, your PR fixes the issue I described. However it does not seem like proper solution because you just deleted some code. I would guess it was put there for a reason :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants