You are here

protected function AddFormBase::buildCurrentSelectionArea in Drupal 9

Same name and namespace in other branches
  1. 8 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
Form constructor.

File

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

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