function AddFormBase::buildCurrentSelectionArea

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

Returns a render array containing the current selection.

Parameters

array $form: The complete form.

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

Return value

array A render array containing the current selection.

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

File

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

Class

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

Namespace

Drupal\media_library\Form

Code

protected function buildCurrentSelectionArea(array $form, FormStateInterface $form_state) {
    $pre_selected_items = $this->getPreSelectedMediaItems($form_state);
    if (!$pre_selected_items || !$this->isAdvancedUi()) {
        return [];
    }
    $selection = [
        '#type' => 'details',
        '#theme_wrappers' => [
            'details__media_library_add_form_selected_media',
        ],
        '#open' => FALSE,
        '#title' => $this->t('Additional selected media'),
    ];
    foreach ($pre_selected_items as $media_id => $media) {
        $selection[$media_id] = $this->buildSelectedItemElement($media, $form, $form_state);
    }
    return $selection;
}

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