public function HealthCheckSettingsForm::validateForm in Health Check Url 8
Same name and namespace in other branches
- 8.3 src/Form/HealthCheckSettingsForm.php \Drupal\health_check_url\Form\HealthCheckSettingsForm::validateForm()
- 8.2 src/Form/HealthCheckSettingsForm.php \Drupal\health_check_url\Form\HealthCheckSettingsForm::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/ HealthCheckSettingsForm.php, line 74
Class
- HealthCheckSettingsForm
- Configure health settings for this site.
Namespace
Drupal\health_check_url\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->isValueEmpty('endpoint')) {
$form_state
->setValueForElement($form['endpoint'], '/health');
}
if ($form_state
->isValueEmpty('string')) {
$form_state
->setValueForElement($form['string'], 'Passed');
}
if (($value = $form_state
->getValue('endpoint')) && $value[0] !== '/') {
$form_state
->setErrorByName('endpoint', $this
->t("The path '%path' has to start with a slash.", [
'%path' => $form_state
->getValue('endpoint'),
]));
}
}