You are here

protected function FileUploadForm::buildEntityFormElement in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media_library/src/Form/FileUploadForm.php \Drupal\media_library\Form\FileUploadForm::buildEntityFormElement()
  2. 9 core/modules/media_library/src/Form/FileUploadForm.php \Drupal\media_library\Form\FileUploadForm::buildEntityFormElement()

File

core/modules/media_library/src/Form/FileUploadForm.php, line 258

Class

FileUploadForm
Creates a form to create media entities from uploaded files.

Namespace

Drupal\media_library\Form

Code

protected function buildEntityFormElement(MediaInterface $media, array $form, FormStateInterface $form_state, $delta) {
  $element = parent::buildEntityFormElement($media, $form, $form_state, $delta);
  $source_field = $this
    ->getSourceFieldName($media->bundle->entity);
  if (isset($element['fields'][$source_field])) {
    $element['fields'][$source_field]['widget'][0]['#process'][] = [
      static::class,
      'hideExtraSourceFieldComponents',
    ];
  }
  return $element;
}