Hi, I can’t get my radio button to be checked by default, here is what I
have:
<%= f.radio_button :gender, “male”, :checked => ‘true’ %>
Male
<%= f.radio_button :gender, “female” %>
Female
Hi, I can’t get my radio button to be checked by default, here is what I
have:
<%= f.radio_button :gender, “male”, :checked => ‘true’ %>
Male
Female
Here is the generated html:
Rails is going nuts here, why is Rails generating the id
“user_gender_male”??? That’s why everything is going wrong.
I think, the way you are using the :checked option may be wrong.
Try with,
:checked => true
:checked => ‘checked’
Karthi kn wrote:
I think, the way you are using the :checked option may be wrong.
Try with,
:checked => true
:checked => ‘checked’
Returns a radio button tag for accessing a specified attribute
(identified by method) on an object assigned to the template (identified
by object). If the current value of method is tag_value the radio button
will be checked. Additional options on the input tag can be passed as a
hash with options.
Examples
radio_button(“post”, “category”, “rails”)
value=“rails” checked=“checked” />
or just do :checked => ‘checked’ yourself in the options.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs