You are here

protected function MediaBulkUploadForm::prepareFormValues in Media Bulk Upload 8

Prepare form submitted values.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: Form State.

Return value

$this Media Bulk Upload Form.

1 call to MediaBulkUploadForm::prepareFormValues()
MediaBulkUploadForm::submitForm in src/Form/MediaBulkUploadForm.php
Submit handler to create the file entities and media entities.

File

src/Form/MediaBulkUploadForm.php, line 509

Class

MediaBulkUploadForm
Class BulkMediaUploadForm.

Namespace

Drupal\media_bulk_upload\Form

Code

protected function prepareFormValues(FormStateInterface $form_state) {

  // If the shared name is empty, remove it from the form state.
  // Otherwise the extractFormValues function will override with an empty value.
  $shared = $form_state
    ->getValue([
    'fields',
    'shared',
  ]);
  if (empty($shared['name'][0]['value'])) {
    unset($shared['name']);
    $form_state
      ->setValue([
      'fields',
      'shared',
    ], $shared);
  }
  return $this;
}