You are here

protected function TourTipForm::actionsElement in Tour UI 8

Returns the action form element for the current entity form.

1 call to TourTipForm::actionsElement()
TourTipForm::buildForm in src/Form/TourTipForm.php
Form constructor.

File

src/Form/TourTipForm.php, line 82

Class

TourTipForm
Form controller for the tour tip plugin edit forms.

Namespace

Drupal\tour_ui\Form

Code

protected function actionsElement(array $form, FormStateInterface $form_state) {
  $element = $this
    ->actions($form, $form_state);
  if (isset($element['delete'])) {

    // Move the delete action as last one, unless weights are explicitly
    // provided.
    $delete = $element['delete'];
    unset($element['delete']);
    $element['delete'] = $delete;
    $element['delete']['#button_type'] = 'danger';
  }
  if (isset($element['submit'])) {

    // Give the primary submit button a #button_type of primary.
    $element['submit']['#button_type'] = 'primary';
  }
  $count = 0;
  foreach (Element::children($element) as $action) {
    $element[$action] += [
      '#weight' => ++$count * 5,
    ];
  }
  if (!empty($element)) {
    $element['#type'] = 'actions';
  }
  return $element;
}