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
# Let's say that @post.category returns "rails": radio_button("post", "category", "rails") radio_button("post", "category", "java") # => <input name="post[category]" checked="checked" type="radio" value="rails" /> # <input name="post[category]" type="radio" value="java" /> radio_button("user", "receive_newsletter", "yes") radio_button("user", "receive_newsletter", "no") # => <input name="user[receive_newsletter]" type="radio" value="yes" /> # <input name="user[receive_newsletter]" checked="checked" type="radio" value="no" />
Source Code
# File action_view/helpers/form_helper.rb, line 440 def radio_button(object_name, method, tag_value, options = {}) InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_radio_button_tag(tag_value, options) end
<code/>and<pre/>for code samples.