function AddFormBase::buildActions

Same name in other branches
  1. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::buildActions()
  2. 8.9.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::buildActions()
  3. 10 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::buildActions()

Returns an array of supported actions for the form.

Parameters

array $form: The complete form.

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

Return value

array An actions element containing the actions of the form.

1 call to AddFormBase::buildActions()
AddFormBase::buildForm in core/modules/media_library/src/Form/AddFormBase.php

File

core/modules/media_library/src/Form/AddFormBase.php, line 461

Class

AddFormBase
Provides a base class for creating media items from within the media library.

Namespace

Drupal\media_library\Form

Code

protected function buildActions(array $form, FormStateInterface $form_state) {
    $actions = [
        '#type' => 'actions',
        'save_select' => [
            '#type' => 'submit',
            '#button_type' => 'primary',
            '#value' => $this->t('Save'),
            '#ajax' => [
                'callback' => '::updateLibrary',
                'wrapper' => 'media-library-add-form-wrapper',
            ],
        ],
    ];
    if ($this->isAdvancedUi()) {
        $actions['save_select']['#value'] = $this->t('Save and select');
        $actions['save_insert'] = [
            '#type' => 'submit',
            '#value' => $this->t('Save and insert'),
            '#ajax' => [
                'callback' => '::updateWidget',
                'wrapper' => 'media-library-add-form-wrapper',
            ],
        ];
    }
    return $actions;
}

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