public function DemoDumpForm::validateForm in Demonstration site (Sandbox / Snapshot) 8
Validate form values.
Overrides FormBase::validateForm
File
- src/
Form/ DemoDumpForm.php, line 57
Class
Namespace
Drupal\demo\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!$form_state
->getValue([
'confirm',
])) {
$fileconfig = demo_get_fileconfig($form_state
->getValue([
'dump',
'filename',
]));
if (file_exists($fileconfig['infofile']) || file_exists($fileconfig['sqlfile'])) {
$form_state
->set([
'demo',
'dump_exists',
], TRUE);
$form_state
->setErrorByName('dump[filename]', t('File exists'));
$form_state
->setRebuild(TRUE);
}
}
}