You are here

protected static function MediaForm::getNewMediaItems in GridStack 8.2

Gets newly selected media items.

2 calls to MediaForm::getNewMediaItems()
MediaForm::addItems in src/Plugin/gridstack/stylizer/MediaForm.php
Updates the field state and flags the form for rebuild.
MediaForm::updateWidget in src/Plugin/gridstack/stylizer/MediaForm.php
AJAX callback to update the widget when the selection changes.

File

src/Plugin/gridstack/stylizer/MediaForm.php, line 630

Class

MediaForm
Provides the media form for Layout Builder integration.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

protected static function getNewMediaItems(array $element, FormStateInterface $form_state) {

  // Get the new media IDs passed to our hidden button. We need to use the
  // actual user input, since when #limit_validation_errors is used, the
  // unvalidated user input is not added to the form state.
  // @see FormValidator::handleErrorsWithLimitedValidation()
  $value = self::getUserInputValues($element, $form_state);
  $mid = empty($value['media_library_selection']) ? '' : $value['media_library_selection'];
  return $mid ? Media::loadMultiple([
    $mid,
  ]) : [];
}