function ConfigImportForm::validateForm

Same name in other branches
  1. 9 core/modules/config/src/Form/ConfigImportForm.php \Drupal\config\Form\ConfigImportForm::validateForm()
  2. 10 core/modules/config/src/Form/ConfigImportForm.php \Drupal\config\Form\ConfigImportForm::validateForm()
  3. 11.x core/modules/config/src/Form/ConfigImportForm.php \Drupal\config\Form\ConfigImportForm::validateForm()

Overrides FormBase::validateForm

File

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

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.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.