collection_radio_buttons() is defined in the rails 5.1 docs like this:
collection_radio_buttons(
method, collection,
value_method,
text_method,
options = {},
html_options = {}, &block
)
There is no explanation in the docs for what the options argument is. The simple_form docs say that there is an option called item_wrapper_tag.
I've been trying this:
<%= form_for(:an_article, url: "blah") do |f| %>
<%= f.collection_radio_buttons(
:author_id, Author.all,
:id,
:name_with_initial,
{item_wrapper_tag: :div} #<=== HERE *****
)
%>
<% end %>
I've tried every combination of symbols and strings for the key, item_wrapper_tag, and the value, div, and nothing succeeds in wrapping each radio button in a div.
Does anyone know if rails has a similar option as item_wrapper_tag?
Okay, I figured it out:
radio_buttonandlabelare builtin methods for the |b|uilder object:Additional info:
When you use
form_for(), theobjectargument is the object encapsulated by f, so you omit the object argument:and
methodis called on this object: