how to change class of a label for checkboxes in simple_form how to change class of a label for checkboxes in simple_form ruby-on-rails ruby-on-rails

how to change class of a label for checkboxes in simple_form


I wanted to give an update to this answer in case someone comes here looking for a way to do this as I did.

You can give the label a class with this option :item_wrapper_class => 'class_goes_here'

Here is a full example:

= user.input :resident,              :collection => [["In the U.S", true],["Outside the U.S.", false]],              :label_method => :first,              :value_method => :last,             :as => :radio_buttons,              :label => "Where is your principle residence?",             :item_wrapper_class => 'inline'


If you want you can pass new_class to the label doing something like:

<%= f.collection_check_boxes attribute, collection, value_method, text_method do |b|       b.label(class: 'new_class') {b.check_box + b.text}end %>


You should be able to set :input_html on your form input.

Somthing like:

f.input :something, :as => :check_box, :input_html => { :class => "myclass" }

ian.