bootstrap_form
bootstrap_form copied to clipboard
label_class ignored on collection_check_boxes
I want to add additional classes to the checkboxes in a collection rendered with collection_check_boxes
. According to the documentation, "Other options [than :label
, :hide_label
, :help
] will be forwarded to the radio_button
/check_box method
".
But the class is not added to the checkboxes within the collection.
Digging into the code, the option is present in the call to BootstrapForm::Inputs::InputsCollection#inputs_collection
. But BootstrapForm::FormGroupBuilder#form_group_builder
filters :label_class
(amongst others) from options and this filtered options leak into the calling method. Or is this intended?
Release used: 4.2.0
Thank you for the detailed report. We appreciate all feedback, but you've provided lots of useful information for us. On the odd chance that you have time to submit a pull request, feel free to do so. If you plan to submit a PR, just assign this issue to yourself (upper left of this page). Otherwise, we will look into it.
It looks like the documentation has not been keeping up-to-date with the code. A number of options are not forwarded to the radio_button
and check_box
methods, but this is on purpose.
However, I believe I may have seen what's causing you a problem. Before I actually make any changes, can you please clarify which options you're trying to pass through to the check box and/or its label?
For my use case, I need to pass :label_class
to the labels.
Thanks. That helps clarify things.
We can't change what :label_class
on collection_check_boxes
does. It sets the class on the label for the group of buttons, so we can't also use it to pass a class down to the labels of the individual check boxes without breaking existing code that uses collection_check_boxes
.
I suspect the fix to #477 would help in your case. A block on collection_check_boxes
would allow you to call check_box
directly with whatever options you want. What do you think?
A fix of #477 would definitely help me. As a matter of fact, my current workaround is to use collection_check_boxes_without_bootstrap
.