public static function ImageButton::preRenderButton in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Render/Element/ImageButton.php \Drupal\Core\Render\Element\ImageButton::preRenderButton()
Prepares a #type 'button' render element for input.html.twig.
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 input.html.twig.
Overrides Button::preRenderButton
File
- core/
lib/ Drupal/ Core/ Render/ Element/ ImageButton.php, line 74 - Contains \Drupal\Core\Render\Element\ImageButton.
Class
- ImageButton
- Provides a form element for a submit button with an image.
Namespace
Drupal\Core\Render\ElementCode
public static function preRenderButton($element) {
$element['#attributes']['type'] = 'image';
Element::setAttributes($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'];
}
$element['#attributes']['class'][] = 'js-form-submit';
$element['#attributes']['class'][] = 'form-submit';
if (!empty($element['#attributes']['disabled'])) {
$element['#attributes']['class'][] = 'is-disabled';
}
return $element;
}