theme_checkbox

  1. drupal
    1. 4.7
    2. 5
    3. 6 form.inc
    4. 7 form.inc
Versions
4.7 – 6 theme_checkbox($element)
7 theme_checkbox($variables)

Format a checkbox.

Parameters

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

Return value

A themed HTML string representing the checkbox.

Related topics

Code

includes/form.inc, line 1309

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

  if (!is_null($element['#title'])) {
    $checkbox = '<label class="option">' . $checkbox . ' ' . $element['#title'] . '</label>';
  }

  unset($element['#title']);
  return theme('form_element', $element, $checkbox);
}
?>