FYI: you can write <%= radio_button_tag "contact[default_telephone]" %> as <%= radio_button_tag :contact, index: :default_telephone %>, which leads to same name, but it feels a bit more 'railsy'.
He/Him/His
I'm a Software Engineer and a teacher.
There's no feeling quite like the one you get when you watch someone's eyes light up learning something they didn't know.
According to the documentation the second argument passed to radio_button_tag is the value of the input. Writing the tag the way you did gives me a radio button that looks like this:
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.
He/Him/His
I'm a Software Engineer and a teacher.
There's no feeling quite like the one you get when you watch someone's eyes light up learning something they didn't know.
FYI: you can write
<%= radio_button_tag "contact[default_telephone]" %>as<%= radio_button_tag :contact, index: :default_telephone %>, which leads to same name, but it feels a bit more 'railsy'.I'm not seeing that.
According to the documentation the second argument passed to
radio_button_tagis the value of the input. Writing the tag the way you did gives me a radio button that looks like this:I tried a few other variations and none gave e a properly formatted radio button.
Sorry, I was a bit quick to reply:
should give you what you want, considering you have to have accessors for
default_telephone_indexon 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 thephoneNumberformbuilder.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_buttonon the formbuilder, not on_tagmethods.At that makes more sense :)