public function MoAuthSupport::validateForm in Google Authenticator / 2 Factor Authentication - 2FA 8.2
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/ MoAuthSupport.php, line 196 - Contains support form for miniOrange 2FA Login Module.
Class
- MoAuthSupport
- Showing Support form info.
Namespace
Drupal\miniorange_2fa\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state
->getValues();
if ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-support') {
if (!\Drupal::service('email.validator')
->isValid($form_values['mo_auth_support_email_address'])) {
$form_state
->setErrorByName('mo_auth_support_email_address', $this
->t('The email address is not valid.'));
}
if (empty($form_values['mo_auth_support_query'])) {
$form_state
->setErrorByName('mo_auth_support_query', $this
->t('The <b>Query</b> fields is mandatory'));
}
}
elseif ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-demo-request') {
if (!\Drupal::service('email.validator')
->isValid($form_values['mo_auth_demo_email_address'])) {
$form_state
->setErrorByName('mo_auth_demo_email_address', $this
->t('The email address is not valid.'));
}
if (empty($form_values['mo_auth_demo_description'])) {
$form_state
->setErrorByName('mo_auth_demo_description', $this
->t('The <b>Description</b> fields is mandatory'));
}
}
elseif ($form_values['mo_auth_vertical_tabs__active_tab'] === 'edit-miniorange-feature-request') {
if (!\Drupal::service('email.validator')
->isValid($form_values['mo_auth_feature_email_address'])) {
$form_state
->setErrorByName('mo_auth_feature_email_address', $this
->t('The email address is not valid.'));
}
if (empty($form_values['mo_auth_feature_query'])) {
$form_state
->setErrorByName('mo_auth_feature_query', $this
->t('The <b>Description</b> fields is mandatory'));
}
}
}