function form_pre_render_button

Prepares a #type 'button' render element for theme_input().

Parameters

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

The #button_type property accepts any value, though core themes have CSS that styles the following button_types appropriately: 'primary', 'danger'.

Return value

array The $element with prepared variables ready for theme_input().

Related topics

1 string reference to 'form_pre_render_button'
system_element_info in drupal/core/modules/system/system.module
Implements hook_element_info().

File

drupal/core/includes/form.inc, line 4158
Functions for form and batch generation and processing.

Code

function form_pre_render_button($element) {
  $element['#attributes']['type'] = 'submit';
  element_set_attributes($element, array(
    'id',
    'name',
    'value',
  ));
  $element['#attributes']['class'][] = 'button';
  if (!empty($element['#button_type'])) {
    $element['#attributes']['class'][] = 'button-' . $element['#button_type'];
  }

  // @todo Various JavaScript depends on this button class.
  $element['#attributes']['class'][] = 'form-submit';
  if (!empty($element['#attributes']['disabled'])) {
    $element['#attributes']['class'][] = 'form-button-disabled';
  }
  return $element;
}