public function DbMaintenanceAdminSettings::validateForm in DB Maintenance 8
Same name and namespace in other branches
- 2.0.x src/Form/DbMaintenanceAdminSettings.php \Drupal\db_maintenance\Form\DbMaintenanceAdminSettings::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/ DbMaintenanceAdminSettings.php, line 175 - Contains \Drupal\db_maintenance\Form\DbMaintenanceAdminSettings.
Class
Namespace
Drupal\db_maintenance\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Check time interval.
if ($form_state
->getValue('use_time_interval') == TRUE) {
// Check start value.
$time = $form_state
->getValue('time_interval_start');
if (!IntervalHandler::checkTime($time)) {
$form_state
->setErrorByName('time_interval_start', $this
->t('Invalid time format. Should be 24 hour format H:i (HH:MM) like 23:30 or 01:00.'));
}
// Check end value.
$time = $form_state
->getValue('time_interval_end');
if (!IntervalHandler::checkTime($time)) {
$form_state
->setErrorByName('time_interval_end', $this
->t('Invalid time format. Should be 24 hour format H:i (HH:MM) like 23:30 or 01:00.'));
}
}
}