ConfigImportForm::validateForm

public ConfigImportForm::validateForm(array &$form, FormStateInterface $form_state)

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormBase::validateForm

File

core/modules/config/src/Form/ConfigImportForm.php, line 75

Class

ConfigImportForm
Defines the configuration import form.

Namespace

Drupal\config\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $all_files = $this->getRequest()->files->get('files', []);
  if (!empty($all_files['import_tarball'])) {
    $file_upload = $all_files['import_tarball'];
    if ($file_upload->isValid()) {
      $form_state->setValue('import_tarball', $file_upload->getRealPath());
      return;
    }
  }

  $form_state->setErrorByName('import_tarball', $this->t('The file could not be uploaded.'));
}
doc_Drupal
2016-10-29 08:53:47
Comments
Leave a Comment

Please login to continue.