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

Already on GitHub? Sign in to your account

Add ability to use CSS class for label of item in the collection for radio and checkbox. #717

wants to merge 3 commits into


None yet
5 participants

No description provided.


rafaelfranca commented Dec 28, 2012

Thank you.

Why do you need it?

When using twitter bootstrap, with the combination of sibling selectors, this allows presentation of labels as bootstrap-styled buttons.

@rafaelfranca rafaelfranca commented on an outdated diff Jan 1, 2013

@@ -97,7 +99,8 @@ def collection_radio_buttons(attribute, collection, value_method, text_method, o
if block_given?
yield builder
- builder.radio_button + builder.label(:class => "collection_radio_buttons")
+ item_label_class = options[:item_label_class]

rafaelfranca Jan 1, 2013


I dont think we need this local variable.

builder.radio_button + builder.label(:class => "collection_radio_buttons #{options[:item_label_class]}".strip)

rafaelfranca commented Jan 2, 2013

Seems good.

@carlosantoniodasilva @nashby objections?


nashby commented Jan 2, 2013

@rafaelfranca looks good. And we definitely need to mention these options in README.


carlosantoniodasilva commented Jan 14, 2013

I'd rather not add new options/APIs considering that you're able to achieve the same results with the currently supported block version. The idea of adding support for blocks with the builder was for people that need to customize the output somehow (a very frequent question), and label classes seem to fall into that category.

@yurikoval can you give a bit more context about the problem you're trying to solve, with some code examples? Thanks.


rafaelfranca commented Jan 22, 2013

Yes. Agree with @carlosantoniodasilva.

@yurikoval thank you for the pull request

flyfy1 commented Aug 23, 2017

I have similar needs -- our own style guide requires me to apply a class on the item level of a collection.

Regarding with the currently supported block version, would anyone point me to the reference for that? Thanks! @carlosantoniodasilva @rafaelfranca

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