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

Returns an array of supported actions for the current entity form.

This function generates a list of Form API elements which represent actions supported by the current entity form.

@todo Consider introducing a 'preview' action here, since it is used by many entity types.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array An array of supported Form API action elements keyed by name.

15 calls to EntityForm::actions()
ActionFormBase::actions in core/modules/action/src/Form/ActionFormBase.php
Returns an array of supported actions for the current entity form.
BlockContentForm::actions in core/modules/block_content/src/BlockContentForm.php
Returns an array of supported actions for the current entity form.
BlockForm::actions in core/modules/block/src/BlockForm.php
Returns an array of supported actions for the current entity form.
BookOutlineForm::actions in core/modules/book/src/Form/BookOutlineForm.php
Returns an array of supported actions for the current entity form.
DateFormatAddForm::actions in core/modules/system/src/Form/DateFormatAddForm.php
Returns an array of supported actions for the current entity form.

... See full list

24 methods override EntityForm::actions()
ActionFormBase::actions in core/modules/action/src/Form/ActionFormBase.php
Returns an array of supported actions for the current entity form.
BlockContentForm::actions in core/modules/block_content/src/BlockContentForm.php
Returns an array of supported actions for the current entity form.
BlockForm::actions in core/modules/block/src/BlockForm.php
Returns an array of supported actions for the current entity form.
BookOutlineForm::actions in core/modules/book/src/Form/BookOutlineForm.php
Returns an array of supported actions for the current entity form.
ContentEntityConfirmFormBase::actions in core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php
Returns an array of supported actions for the current entity form.

... See full list

File

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

Class

EntityForm
Base class for entity forms.

Namespace

Drupal\Core\Entity

Code

protected function actions(array $form, FormStateInterface $form_state) {

  // @todo Consider renaming the action key from submit to save. The impacts
  //   are hard to predict. For example, see
  //   \Drupal\language\Element\LanguageConfiguration::processLanguageConfiguration().
  $actions['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Save'),
    '#submit' => [
      '::submitForm',
      '::save',
    ],
  ];
  if (!$this->entity
    ->isNew() && $this->entity
    ->hasLinkTemplate('delete-form')) {
    $route_info = $this->entity
      ->toUrl('delete-form');
    if ($this
      ->getRequest()->query
      ->has('destination')) {
      $query = $route_info
        ->getOption('query');
      $query['destination'] = $this
        ->getRequest()->query
        ->get('destination');
      $route_info
        ->setOption('query', $query);
    }
    $actions['delete'] = [
      '#type' => 'link',
      '#title' => $this
        ->t('Delete'),
      '#access' => $this->entity
        ->access('delete'),
      '#attributes' => [
        'class' => [
          'button',
          'button--danger',
          'use-ajax',
        ],
        'data-dialog-type' => 'modal',
        'data-dialog-options' => Json::encode([
          'width' => 880,
        ]),
      ],
      '#url' => $route_info,
      '#attached' => [
        'library' => [
          'core/drupal.dialog.ajax',
        ],
      ],
    ];
  }
  return $actions;
}