public function UserExpireSettingsForm::validateForm in User Expire 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/ UserExpireSettingsForm.php, line 120
Class
- UserExpireSettingsForm
- User expire admin settings form.
Namespace
Drupal\user_expire\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
if (!ctype_digit($form_state
->getValue('frequency'))) {
$form_state
->setErrorByName('frequency', $this
->t('Frequency time must be an integer.'));
}
if (!ctype_digit($form_state
->getValue('offset'))) {
$form_state
->setErrorByName('offset', $this
->t('Warning offset time must be an integer.'));
}
foreach ($form_state
->getValue('current_roles') as $rid => $role) {
if ($rid === RoleInterface::ANONYMOUS_ID) {
continue;
}
if (!ctype_digit($form_state
->getValue('user_expire_' . $rid))) {
$form_state
->setErrorByName('user_expire_' . $rid, $this
->t('Inactivity period must be an integer.'));
}
}
}