You are here

protected function AddFormBase::buildActions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::buildActions()
  2. 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
Form constructor.

File

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

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