radio_button_tag(name, value, checked = false, options = {}) public

Creates a radio button; use groups of radio buttons named the same to allow users to select from a group of options.

Options

  • :disabled - If set to true, the user will not be able to use this input.
  • Any other key creates standard HTML options for the tag.

Examples

  radio_button_tag 'gender', 'male'
  # => <input id="gender_male" name="gender" type="radio" value="male" />

  radio_button_tag 'receive_updates', 'no', true
  # => <input checked="checked" id="receive_updates_no" name="receive_updates" type="radio" value="no" />

  radio_button_tag 'time_slot', "3:00 p.m.", false, :disabled => true
  # => <input disabled="disabled" id="time_slot_300_pm" name="time_slot" type="radio" value="3:00 p.m." />

  radio_button_tag 'color', "green", true, :class => "color_input"
  # => <input checked="checked" class="color_input" id="color_green" name="color" type="radio" value="green" />
Show source
Register or log in to add new notes.