Reputation: 5872
I simply have a form and at the top of my form are some radio buttons. Everything has the "form-control" class and flows perfectly fine horizontally; however, I can't get this same class applied to this:
<%= f.collection_radio_buttons :realm, [['External','External'], ['Internal','Internal']], :first, :last %>
I've been looking around, but can only find others who are doing something completely different.
Upvotes: 1
Views: 1626
Reputation: 725
The syntax is
collection_radio_buttons(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
You don't have any options, so you need to supply an empty hash before the html_options
hash.
<%= f.collection_radio_buttons :parent_id, [['External','External'], ['Internal','Internal']], :first, :last, {}, {class: 'form-control'} %>
Upvotes: 0
Reputation: 938
Do you want the form-control class on both the button and label? Then you are looking for something like this:
<%= f.collection_radio_buttons :realm, [['External','External'], ['Internal','Internal']], :first, :last do |b| %>
<%- b.label(class: "form-control") { b.radio_button(class: "form-control") } %>
<% end %>
Upvotes: 2