function form_pre_render_image_button

Prepares a #type 'image_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, #title, #src.

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_image_button'
system_element_info in drupal/core/modules/system/system.module
Implements hook_element_info().

File

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

Code

function form_pre_render_image_button($element) {
  $element['#attributes']['type'] = 'image';
  element_set_attributes($element, array(
    'id',
    'name',
    'value',
  ));
  $element['#attributes']['src'] = file_create_url($element['#src']);
  if (!empty($element['#title'])) {
    $element['#attributes']['alt'] = $element['#title'];
    $element['#attributes']['title'] = $element['#title'];
  }
  $element['#attributes']['class'][] = 'image-button';
  if (!empty($element['#button_type'])) {
    $element['#attributes']['class'][] = 'image-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'][] = 'image-button-disabled';
  }
  return $element;
}