You are here

public function MediaSubFormManager::configureSharedFields in Media Bulk Upload 8

Configure all the shared fields.

Will set all the correct parents and make all the fields optional.

Parameters

array $elements: Form elements from the media type form.

array $allowedFields: Fields that are allowed to be shown in the media bulk upload form.

Return value

$this MediaBulkUploadForm.

Overrides MediaSubFormManagerInterface::configureSharedFields

1 call to MediaSubFormManager::configureSharedFields()
MediaSubFormManager::buildMediaSubForm in src/MediaSubFormManager.php

File

src/MediaSubFormManager.php, line 223

Class

MediaSubFormManager
Class MediaSubFormManager.

Namespace

Drupal\media_bulk_upload

Code

public function configureSharedFields(array &$elements, array $allowedFields) {
  $children = Element::children($elements);
  foreach ($children as $child) {
    if (!in_array($child, $allowedFields, TRUE)) {
      unset($elements[$child]);
      continue;
    }
    $this
      ->forceFieldsAsOptional($elements[$child]);
  }
  return $this;
}