You are here

public function EmailVerifyAdminForm::buildForm in Email Verify 8.2

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/EmailVerifyAdminForm.php, line 64
Contains \Drupal\email_verify\Form\EmailVerifyAdminForm.

Class

EmailVerifyAdminForm
Provides a form for administering Email Verify configuration.

Namespace

Drupal\email_verify\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('email_verify.settings');
  $form['active'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable Email Verify to verify email adresses'),
    '#default_value' => $config
      ->get('active'),
    '#description' => $this
      ->t('When activated, Email Verify will check full email addresses for validity. When unchecked, Email Verify will just check hosts.'),
  ];
  $form['test_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Testing options'),
    '#collapsible' => TRUE,
    '#description' => t("If the test fails when checking whether this module will work on your system or not, you can try changing the options below to see if they will work better for you."),
  );
  $form['test_options']['host_name'] = array(
    '#type' => 'textfield',
    '#title' => t("Host name"),
    '#default_value' => $config
      ->get('host_name'),
    '#description' => t('The name of the host to test with. The default is "drupal.org".'),
  );
  $form['test_options']['timeout'] = array(
    '#type' => 'textfield',
    '#title' => t("Timeout"),
    '#default_value' => $config
      ->get('timeout'),
    '#description' => t('The connection timeout, in seconds. The default is "15".'),
  );
  $form['verify_methods'] = array(
    '#type' => 'fieldset',
    '#title' => t('Methods to use'),
    '#collapsible' => TRUE,
    '#description' => t("Check the boxes for the various methods to use when verifying email addresses. If you find you're getting lots of false positives nad/or false negatives, try changing which options are enabled."),
  );
  $form['verify_methods']['checkdnsrr'] = array(
    '#type' => 'checkbox',
    '#title' => t("Check for any DNS records"),
    '#default_value' => $config
      ->get('checkdnsrr'),
    '#description' => t("Use PHP's checkdnsrr() function to see if there are any DNS records associated with the email address' domain name."),
  );
  $form['verify_methods']['gethostbyname'] = array(
    '#type' => 'checkbox',
    '#title' => t("Check for a valid IPv4 address"),
    '#default_value' => $config
      ->get('gethostbyname'),
    '#description' => t("Use PHP's gethostbyname() function to see if a valid IPv4 address is associated with the email address' domain name."),
  );
  $form['verify_methods']['add_dot'] = array(
    '#type' => 'checkbox',
    '#title' => t("Add a dot to the domain"),
    '#default_value' => $config
      ->get('add_dot'),
    '#description' => t("For hosts that add their own domain to the end of the domain in the email address, this adds an additional '.' to the end of the email address domain, so that the check will not fail at the wrong time."),
  );
  return parent::buildForm($form, $form_state);
}