How to name the blank value in select?

It depends on how you are constructing your options for select. If you’re doing it like the code below, just pass a string into the :include blank. select(“post”, “person_id”, Person.all.collect {|p| [ p.name, p.id ] }, {:include_blank => ‘Some text here’}) If you’re setting the options with a options_for_select(), then you can do something like … Read more

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 … Read more

How do I add HTML attributes to select options with Simple Form Rails?

You’re close! easiest way is actually not using simple_form here. here’s the simple_form documentation <% options = @group.map { |g| [g.name, g.id, {‘data-type’ => g.group_type}] } %> <%= f.input :group, label: ‘Group’ do %> <%= f.select :group, options, include_blank: ‘Select a Group’, class: ‘form-control’ %> <% end %> For your exact code it would be: … Read more

Simple form association custom label name

You’ll have to use the :label_method option for this. <%= f.association :owner_type, :include_blank => false, :label_method => lambda { |owner| “#{owner.name} | #{owner.subtype_name}” } %> or, if you define a select_label method on the owner’s class, you can do <%= f.association :owner_type, :include_blank => false, :label_method => :select_label %>