function AddFormBase::validateMediaEntity

Same name in other branches
  1. 9 core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::validateMediaEntity()
  2. 8.9.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::validateMediaEntity()
  3. 11.x core/modules/media_library/src/Form/AddFormBase.php \Drupal\media_library\Form\AddFormBase::validateMediaEntity()

Validate a created media item.

Parameters

\Drupal\media\MediaInterface $media: The media item to validate.

array $form: The complete form.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

int $delta: The delta of the media item.

1 call to AddFormBase::validateMediaEntity()
AddFormBase::validateForm in core/modules/media_library/src/Form/AddFormBase.php
Form validation handler.

File

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

Class

AddFormBase
Provides a base class for creating media items from within the media library.

Namespace

Drupal\media_library\Form

Code

protected function validateMediaEntity(MediaInterface $media, array $form, FormStateInterface $form_state, $delta) {
    $form_display = EntityFormDisplay::collectRenderDisplay($media, 'media_library');
    $form_display->extractFormValues($media, $form['media'][$delta]['fields'], $form_state);
    $form_display->validateFormValues($media, $form['media'][$delta]['fields'], $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.