function theme_radio

7.x theme_radio($variables)
5.x theme_radio($element)
6.x theme_radio($element)

Returns HTML for a radio button form element.

Note: The input "name" attribute needs to be sanitized before output, which is currently done by passing all attributes to drupal_attributes().


$variables: An associative array containing:

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

Related topics

12 string references to the theme hook from theme_radio()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

ajax_pre_render_element in drupal/includes/
Adds Ajax information about an element to communicate with JavaScript.
DrupalRenderTestCase::testDrupalRenderFormElements in drupal/modules/simpletest/tests/common.test
Test rendering form elements without passing through form_builder().
DrupalWebTestCase::handleForm in drupal/modules/simpletest/drupal_web_test_case.php
Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
drupal_common_theme in drupal/includes/
Provides theme registration for themes across .inc files.
FormElementTestCase::testOptions in drupal/modules/simpletest/tests/form.test
Tests expansion of #options for #type checkboxes and radios.

... See full list


drupal/includes/, line 2870
Functions for form and batch generation and processing.


function theme_radio($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'radio';
  element_set_attributes($element, array('id', 'name','#return_value' => 'value'));

  if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
    $element['#attributes']['checked'] = 'checked';
  _form_set_class($element, array('form-radio'));

  return '<input' . drupal_attributes($element['#attributes']) . ' />';