public function SettingsForm::validateForm in Replication 8
Same name and namespace in other branches
- 8.2 src/Form/SettingsForm.php \Drupal\replication\Form\SettingsForm::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/ SettingsForm.php, line 140
Class
- SettingsForm
- Class SettingsForm.
Namespace
Drupal\replication\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
$storage = \Drupal::entityTypeManager()
->getStorage('user');
$uid = trim($form_state
->getValue('uid'));
if ($form_state
->getValue('mapping_type') === 'uid' && is_numeric($uid)) {
if (!$storage
->load($uid)) {
$form_state
->setErrorByName('uid', "Provided UID doesn't exist.");
}
}
elseif ($form_state
->getValue('mapping_type') === 'uid' && !is_numeric($uid)) {
$form_state
->setErrorByName('uid', 'Empty or wrong format for the UID field.');
}
}