Prepares a #type 'image_button' render element for theme_input().
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'.
array The $element with prepared variables ready for theme_input().
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;
}