public function ContentImportForm::validateForm in Content Synchronization 8
Same name and namespace in other branches
- 8.2 src/Form/ContentImportForm.php \Drupal\content_sync\Form\ContentImportForm::validateForm()
- 3.0.x src/Form/ContentImportForm.php \Drupal\content_sync\Form\ContentImportForm::validateForm()
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
- src/
Form/ ContentImportForm.php, line 48
Class
- ContentImportForm
- Defines the content import form.
Namespace
Drupal\content_sync\FormCode
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.'));
}