public function CloseBlockSettingsForm::validateForm in Close Block 8
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/ CloseBlockSettingsForm.php, line 108
Class
- CloseBlockSettingsForm
- Provides a module settings form.
Namespace
Drupal\closeblock\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue('close_block_speed') < 0) {
$form_state
->setErrorByName('close_block_speed', $this
->t('Animation speed can not be negative.'));
}
elseif ($form_state
->getValue('close_block_speed') > 5000) {
$form_state
->setErrorByName('close_block_speed', $this
->t('Animation speed can not be more that 5000'));
}
if ($form_state
->getValue('reset_cookie_time') < 0) {
$form_state
->setErrorByName('reset_cookie_time', $this
->t('Reset Cookie Value cannot be negative.'));
}
elseif ($form_state
->getValue('reset_cookie_time') > 2030) {
$form_state
->setErrorByName('reset_cookie_time', $this
->t('Reset Cookie Value cannot be more that 2030'));
}
}