function AddFormBase::getAddedMediaItems
Same name in other branches
- 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getAddedMediaItems()
- 8.9.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getAddedMediaItems()
- 10 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::getAddedMediaItems()
Get all added media items from the form state.
Parameters
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
Return value
\Drupal\media\MediaInterface[] An array containing the added media items keyed by delta. The media items won't have an ID until they are saved in ::submitForm().
5 calls to AddFormBase::getAddedMediaItems()
- AddFormBase::buildForm in core/
modules/ media_library/ src/ Form/ AddFormBase.php - AddFormBase::getCurrentMediaItems in core/
modules/ media_library/ src/ Form/ AddFormBase.php - Get all pre-selected and added media items from the form state.
- AddFormBase::submitForm in core/
modules/ media_library/ src/ Form/ AddFormBase.php - AddFormBase::updateLibrary in core/
modules/ media_library/ src/ Form/ AddFormBase.php - AJAX callback to send the new media item(s) to the media library.
- AddFormBase::validateForm in core/
modules/ media_library/ src/ Form/ AddFormBase.php
File
-
core/
modules/ media_library/ src/ Form/ AddFormBase.php, line 863
Class
- AddFormBase
- Provides a base class for creating media items from within the media library.
Namespace
Drupal\media_library\FormCode
protected function getAddedMediaItems(FormStateInterface $form_state) {
return $form_state->get('media') ?: [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.