You are here

public function MiniorangeSupport::validateForm in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 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/MiniorangeSupport.php, line 173
Contains support form for miniOrange 2FA Login Module.

Class

MiniorangeSupport
Showing Support form info.

Namespace

Drupal\miniorange_saml\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $form_values = $form_state
    ->getValues();

  //echo"<pre>";print_r($form_values);exit;
  if ($form_values['mo_saml_vertical_tabs__active_tab'] === 'edit-miniorange-support') {
    if (!\Drupal::service('email.validator')
      ->isValid($form_values['mo_saml_support_email_address'])) {
      $form_state
        ->setErrorByName('mo_saml_support_email_address', $this
        ->t('The email address is not valid.'));
    }
    if (empty($form_values['mo_saml_support_query'])) {
      $form_state
        ->setErrorByName('mo_saml_support_query', $this
        ->t('The <b><u>Query</u></b> fields is mandatory'));
    }
  }
  elseif ($form_values['mo_saml_vertical_tabs__active_tab'] === 'edit-miniorange-demo-request') {
    if (!\Drupal::service('email.validator')
      ->isValid($form_values['mo_saml_demo_email_address'])) {
      $form_state
        ->setErrorByName('mo_saml_demo_email_address', $this
        ->t('The email address is not valid.'));
    }
    if (empty($form_values['mo_saml_demo_description'])) {
      $form_state
        ->setErrorByName('mo_saml_demo_description', $this
        ->t('The <b><u>Description</u></b> fields is mandatory'));
    }
  }
  elseif ($form_values['mo_saml_vertical_tabs__active_tab'] === 'edit-miniorange-feature-request') {
    if (!\Drupal::service('email.validator')
      ->isValid($form_values['mo_saml_feature_email_address'])) {
      $form_state
        ->setErrorByName('mo_saml_feature_email_address', $this
        ->t('The email address is not valid.'));
    }
    if (empty($form_values['mo_saml_feature_query'])) {
      $form_state
        ->setErrorByName('mo_saml_feature_query', $this
        ->t('The <b><u>Description</u></b> fields is mandatory'));
    }
  }
}