protected function AddFormBase::buildCurrentSelectionArea in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::buildCurrentSelectionArea()
- 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 - Form constructor.
File
- core/
modules/ media_library/ src/ Form/ AddFormBase.php, line 384
Class
- AddFormBase
- Provides a base class for creating media items from within the media library.
Namespace
Drupal\media_library\FormCode
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;
}