public function MediaEditForm::saveMedia in Media Directories 3.x
Same name and namespace in other branches
- 8 modules/media_directories_ui/src/Form/MediaEditForm.php \Drupal\media_directories_ui\Form\MediaEditForm::saveMedia()
- 2.x modules/media_directories_ui/src/Form/MediaEditForm.php \Drupal\media_directories_ui\Form\MediaEditForm::saveMedia()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
\Drupal\Core\Ajax\AjaxResponse
File
- modules/
media_directories_ui/ src/ Form/ MediaEditForm.php, line 348
Class
- MediaEditForm
- Class MediaEditForm
Namespace
Drupal\media_directories_ui\FormCode
public function saveMedia(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$added_media = $form_state
->get('media');
foreach ($added_media as $delta => $media) {
EntityFormDisplay::collectRenderDisplay($media, 'media_library')
->extractFormValues($media, $form['media'][$delta]['fields'], $form_state);
//$this->prepareMediaEntityForSave($media);
$media
->save();
}
$response
->addCommand(new LoadDirectoryContent());
$response
->addCommand(new CloseModalDialogCommand());
return $response;
}