theme_radio

Versions
4.7 – 6
theme_radio($element)
7
theme_radio($variables)

Theme a radio button form element.

Parameters

$variables An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #required, #return_value, #value, #attributes, #title, #description

Return value

A themed HTML string representing the form item group.

Related topics

Code

includes/form.inc, line 1791

<?php
function theme_radio($variables) {
  $element = $variables['element'];
  _form_set_class($element, array('form-radio'));
  $output = '<input type="radio" ';
  $output .= 'id="' . $element['#id'] . '" ';
  $output .= 'name="' . $element['#name'] . '" ';
  $output .= 'value="' . $element['#return_value'] . '" ';
  $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
  $output .= drupal_attributes($element['#attributes']) . ' />';

  if (isset($element['#title'])) {
    $output = '<label class="option" for="' . $element['#id'] . '">' . $output . ' ' . $element['#title'] . '</label>';
  }

  return $output;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.