You are here

public function FileUploadForm::processUploadElement in Media Directories 3.x

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

Processes an upload (managed_file) 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 77

Class

FileUploadForm

Namespace

Drupal\media_directories_ui\Form

Code

public function processUploadElement(array $element, FormStateInterface $form_state) {
  $element['upload_button']['#submit'] = [
    '::uploadButtonSubmit',
  ];

  // Limit the validation errors to make sure
  // FormValidator::handleErrorsWithLimitedValidation doesn't remove the
  // current selection from the form state.
  // @see Drupal\Core\Form\FormValidator::handleErrorsWithLimitedValidation()
  $element['upload_button']['#limit_validation_errors'] = [
    [
      'upload',
    ],
    [
      'current_selection',
    ],
  ];
  $element['upload_button']['#ajax'] = [
    'callback' => '::updateFormCallback',
    'wrapper' => 'media-library-wrapper',
  ];
  return $element;
}