DEV Community

Discussion on: Rails: Radio Buttons In Nested Forms

Collapse
 
bertbruynooghe profile image
Bert Bruynooghe

Sorry, I was a bit quick to reply:

<%= f.radio_button :default_telephone_index, phone_form.index %>

should give you what you want, considering you have to have accessors for default_telephone_index on you model/form_object. (Which would be a good approach anyway, since you want as little code as possible in your view.) Also note that the radio_button is on the overall form, not the phoneNumber formbuilder.

Also, the original intent of my comment was to point you to the use of the :index option not to have to compose names yourself, but it only works on methods like radio_button on the formbuilder, not on _tag methods.

Thread Thread
 
yechielk profile image
Yechiel Kalmenson

At that makes more sense :)