How to Create a Radio Button

The Form::radio() method works exactly the same as the Form::checkbox() method except that it automatically sets the type attribute to radio. The method only creates a single radio button so in order to create a group of buttons, just call the method more than once and use the same name.

  echo Form::radio('name', 'yes', TRUE);
  echo Form::radio('name', 'no', FALSE);
  <input type="radio" name="name" value="yes" checked="checked" />
  <input type="radio" name="name" value="no" />

The fourth parameter accepts an array of attributes

  echo Form::radio('name', 'yes', TRUE, array('disabled'=>TRUE));
  <input type="radio" name="name" value="yes" checked="checked" disabled="1" />
how_to_create_a_radio_button.txt · Last modified: 2010/03/02 08:30 by purefusion