Button::preRenderButton

public static Button::preRenderButton($element)

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.

File

core/lib/Drupal/Core/Render/Element/Button.php, line 82

Class

Button
Provides an action button form element.

Namespace

Drupal\Core\Render\Element

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public static function preRenderButton($element) {
  $element['#attributes']['type'] = 'submit';
  Element::setAttributes($element, array('id', 'name', 'value'));
 
  $element['#attributes']['class'][] = 'button';
  if (!empty($element['#button_type'])) {
    $element['#attributes']['class'][] = '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;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.