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
[Form] Add option to add a class to <div class="form-check">
(radio+checkbox)
#36502
Comments
There's something I don't understand. You mentioned that choices are shown/hidden with JavaScript ... so you could add/remove/toggle those CSS classes using JavaScript, right? |
Yeah, sure, there's a workaround: Access the The general issue is that radio buttons are missing some flexibility (which other types do have), since Symfony (in principle) sees them as one field, not as a series of single widgets. |
Yes, this reminds me of the collection type, which didn't have a simple way to customize each collection item (and we made some changes in #36088 to fix that). So, we could do something similar here and allow to define attributes for each choice row. Let's ask @HeahDude what does he think about this. Thanks! |
Thank you for this issue. |
Given that we didn't received the feedback by more people having the need for this feature I am closing here as the desired outcome can be achieved with a custom form type extension and a custom form theme. Thank you for understanding. |
The question is relevant. There is a solution ? |
This is required to turn a simple checkbox into a switch https://getbootstrap.com/docs/5.0/forms/checks-radios/#switches |
This is definitely a necessary feature. Came here, because I also wanted to turn a checkbox into a switch. |
If you need it, build it and submit a PR. This project is open source. |
As this issue was closed with regards to "not enough feedback by more people" I think it is okay, to add ones feedback... Edit: Okay. The behavior is still working as described in the post I linked when enabling bootstrap_4_layout in twig.yaml but gets lost with bootstrap_5_layout |
Solution: How to turn checkboxes into switches with Bootstrap 5.x |
It would be nice to have an option to add a class name here (Bootstrap theme):
https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_4_layout.html.twig#L193
That is the
<div>
around each radio button / checkbox.Suggested name:
choice_row_attr
- sincechoice_attr
addresses the<input>
, androw_attr
the<div>
containing all the radios.So if you either do:
... or ...
...the outcome would be:
My use case:
I'm having a list of like 20 radio buttons, and depending on the user's selection in another field, some of them get hidden (with JavaScript).
Other use case would be to highlight some radios.
The text was updated successfully, but these errors were encountered: