public function FancyLoginSettingsForm::validateForm in Fancy Login 8.2
Same name and namespace in other branches
- 3.0.x src/Form/FancyLoginSettingsForm.php \Drupal\fancy_login\Form\FancyLoginSettingsForm::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/ FancyLoginSettingsForm.php, line 169
Class
- FancyLoginSettingsForm
- Creates the settings form for the fancy login module.
Namespace
Drupal\fancy_login\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$test_values = [
'screen_fade_color',
'screen_fade_z_index',
'login_box_background_color',
'login_box_text_color',
'login_box_border_color',
'login_box_border_width',
'login_box_border_style',
];
foreach ($test_values as $machine_name) {
if (!strlen($form_state
->getValue($machine_name))) {
$form_state
->setError($form[$machine_name], $this
->t('@field must contain a value', [
'@field' => $form[$machien_name]['#title'],
]));
}
}
if (!is_numeric(trim($form_state
->getValue('dim_fade_time')))) {
$form_state
->setError($form['display']['dim_fade_time'], $this
->t('Background Fade Speed must contain a numeric value'));
}
if (!is_numeric(trim($form_state
->getValue('login_box_fade_time')))) {
$form_state
->setError($form['display']['login_box_fade_time'], $this
->t('Login Box Fade Speed must contain a numeric value'));
}
parent::validateForm($form, $form_state);
}