You are here

public static function EntityconnectSubmit::preRenderButton in Entity connect 8.2

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

src/Element/EntityconnectSubmit.php, line 67

Class

EntityconnectSubmit
Provides a custom form submit button for entityconnect.

Namespace

Drupal\entityconnect\Element

Code

public static function preRenderButton($element) {
  $element = parent::preRenderButton($element);

  // Attach entityconnect assets.
  $element['#attached']['library'][] = 'entityconnect/entityconnect';

  // Support Clientside Validation.
  $element['#attributes']['class'][] = 'cancel';
  if (empty($element['#attributes']['title'])) {
    $element['#attributes']['title'] = $element['#add_child'] ? t('Add') : t('Edit');
  }
  return $element;
}