Format a radio button.

Parameters

$title: The label for the radio button.

$name: The internal name used to refer to the button.

$value: The value that the form element takes on when selected.

$checked: Whether the button will be initially selected when the page is rendered.

$description: Explanatory text to display after the form item.

$attributes: An associative array of HTML attributes to add to the button.

$required: Whether the user must select this radio button before submitting the form.

Return value

A themed HTML string representing the radio button.

Related topics

5 calls to form_radio()
filter_admin_overview in modules/filter.module
Menu callback; allows administrators to set up input formats.
node_admin_nodes in modules/node.module
Generate the content administration overview.
system_theme_listing in modules/system.module
Generate a list of all the available theme/style combinations.
system_user in modules/system.module
Implementation of hook_user().
_locale_admin_manage_screen in includes/locale.inc
User interface for the language management screen

File

includes/common.inc, line 1094
Common functions that many Drupal modules will need to reference.

Code

function form_radio($title, $name, $value = 1, $checked = FALSE, $description = NULL, $attributes = NULL, $required = FALSE) {
  $element = '<input type="radio" class="' . _form_get_class('form-radio', $required, _form_get_error($name)) . '" name="edit[' . $name . ']" value="' . check_plain($value) . '"' . ($checked ? ' checked="checked"' : '') . drupal_attributes($attributes) . ' />';
  if (!is_null($title)) {
    $element = '<label class="option">' . $element . ' ' . $title . '</label>';
  }
  return theme('form_element', NULL, $element, $description, $name, $required, _form_get_error($name));
}