Method: ActionView::Helpers::FormHelper#radio_button
- Defined in:
- lib/action_view/helpers/form_helper.rb
#radio_button(object_name, method, tag_value, options = {}) ⇒ Object
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.
To force the radio button to be checked pass :checked => true in the options hash. You may pass HTML options there as well.
Examples
# Let's say that @post.category returns "rails":
("post", "category", "rails")
("post", "category", "java")
# => <input type="radio" id="post_category_rails" name="post[category]" value="rails" checked="checked" />
# <input type="radio" id="post_category_java" name="post[category]" value="java" />
("user", "receive_newsletter", "yes")
("user", "receive_newsletter", "no")
# => <input type="radio" id="user_receive_newsletter_yes" name="user[receive_newsletter]" value="yes" />
# <input type="radio" id="user_receive_newsletter_no" name="user[receive_newsletter]" value="no" checked="checked" />
798 799 800 |
# File 'lib/action_view/helpers/form_helper.rb', line 798 def (object_name, method, tag_value, = {}) InstanceTag.new(object_name, method, self, .delete(:object)).(tag_value, ) end |