function ImageButton::preRenderButton
Same name in other branches
- 9 core/lib/Drupal/Core/Render/Element/ImageButton.php \Drupal\Core\Render\Element\ImageButton::preRenderButton()
- 8.9.x core/lib/Drupal/Core/Render/Element/ImageButton.php \Drupal\Core\Render\Element\ImageButton::preRenderButton()
- 11.x core/lib/Drupal/Core/Render/Element/ImageButton.php \Drupal\Core\Render\Element\ImageButton::preRenderButton()
Overrides Button::preRenderButton
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ ImageButton.php, line 69
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, [
'id',
'name',
'value',
]);
$element['#attributes']['src'] = \Drupal::service('file_url_generator')->generateString($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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.