You are here

function theme_button in Drupal 7

Same name and namespace in other branches
  1. 4 includes/form.inc \theme_button()
  2. 5 includes/form.inc \theme_button()
  3. 6 includes/form.inc \theme_button()

Returns HTML for a button form element.

Parameters

$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #attributes, #button_type, #name, #value.

Related topics

1 theme call to theme_button()
theme_submit in includes/form.inc
Returns HTML for a submit button form element.

File

includes/form.inc, line 3922
Functions for form and batch generation and processing.

Code

function theme_button($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'submit';
  element_set_attributes($element, array(
    'id',
    'name',
    'value',
  ));

  // Remove name attribute, if empty, for W3C compliance.
  if (isset($element['#attributes']['name']) && $element['#attributes']['name'] === '') {
    unset($element['#attributes']['name']);
  }
  $element['#attributes']['class'][] = 'form-' . $element['#button_type'];
  if (!empty($element['#attributes']['disabled'])) {
    $element['#attributes']['class'][] = 'form-button-disabled';
  }
  return '<input' . drupal_attributes($element['#attributes']) . ' />';
}