You are here

public function UsernameCheckSettings::buildForm in Username originality AJAX check 8

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/UsernameCheckSettings.php, line 48
Contains \Drupal\username_check\Form\UsernameCheckSettings.

Class

UsernameCheckSettings

Namespace

Drupal\username_check\Form

Code

public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $form = [];
  $config = \Drupal::config('username_check.settings');
  $form['username_check_mode'] = [
    '#type' => 'radios',
    '#title' => t('Check for usernames pre-existing in system:'),
    '#options' => [
      'auto' => t('On - executes when user leaves username field or upon timer end'),
      'off' => t('Off - No Username checking'),
    ],
    '#default_value' => $config
      ->get('username_check_mode'),
  ];
  $form['username_check_mail_mode'] = [
    '#type' => 'radios',
    '#title' => t('Check for E-mail addresses pre-existing in system:'),
    '#options' => [
      'auto' => t('On - executes when user leaves e-mail field or upon timer end'),
      'off' => t('Off - No E-mail address checking'),
    ],
    '#default_value' => $config
      ->get('username_check_mail_mode'),
  ];
  $form['username_check_delay'] = [
    '#type' => 'textfield',
    '#title' => t('Timer threshold:'),
    '#description' => t('Threshold in seconds (ex: 0.5, 1) for the check to happen.'),
    '#default_value' => $config
      ->get('username_check_delay'),
  ];
  return parent::buildForm($form, $form_state);
}