You are here

public function FileUploadForm::validateUploadElement in Media Directories 8

Same name and namespace in other branches
  1. 3.x modules/media_directories_ui/src/Form/FileUploadForm.php \Drupal\media_directories_ui\Form\FileUploadForm::validateUploadElement()
  2. 2.x modules/media_directories_ui/src/Form/FileUploadForm.php \Drupal\media_directories_ui\Form\FileUploadForm::validateUploadElement()

Validates the upload element.

Parameters

array $element: The upload element.

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

Return value

array The processed upload element.

File

modules/media_directories_ui/src/Form/FileUploadForm.php, line 104

Class

FileUploadForm
A form to upload files.

Namespace

Drupal\media_directories_ui\Form

Code

public function validateUploadElement(array $element, FormStateInterface $form_state) {

  /*    if ($form_state::hasAnyErrors()) {
      // When an error occurs during uploading files, remove all files so the
      // user can re-upload the files.
      $element['#value'] = [];
      }
      $values = $form_state->getValue('upload', []);
      if (count($values['fids']) > $element['#cardinality'] && $element['#cardinality'] !== FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
      $form_state->setError($element, $this->t('A maximum of @count files can be uploaded.', [
      '@count' => $element['#cardinality'],
      ]));
      $form_state->setValue('upload', []);
      $element['#value'] = [];
      }*/
  return $element;
}