function EntityForm::actionsElement

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::actionsElement()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::actionsElement()
  3. 10 core/lib/Drupal/Core/Entity/EntityForm.php \Drupal\Core\Entity\EntityForm::actionsElement()

Returns the action form element for the current entity form.

1 call to EntityForm::actionsElement()
EntityForm::buildForm in core/lib/Drupal/Core/Entity/EntityForm.php
Form constructor.

File

core/lib/Drupal/Core/Entity/EntityForm.php, line 180

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.