You are here

public function DomainRegistrationAdminForm::buildForm in Restrict Domain Registration 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/DomainRegistrationAdminForm.php, line 49

Class

DomainRegistrationAdminForm
Configuration form for Domain Registration.

Namespace

Drupal\domain_registration\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('domain_registration.settings');
  $options = [
    DOMAIN_REGISTRATION_ALLOW => $this
      ->t('Allow only domains listed below to register'),
    DOMAIN_REGISTRATION_DENY => $this
      ->t('Prevent domains listed below from registering'),
  ];
  $form['method'] = [
    '#type' => 'radios',
    '#required' => TRUE,
    '#options' => $options,
    '#title' => $this
      ->t('Restriction Type'),
    '#default_value' => $config
      ->get('method'),
    '#description' => $this
      ->t('Choose which method you would like the domains list to operate. Only allow domains listed to register, or prevent domains listed from registering.'),
  ];
  $form['pattern'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Email domains'),
    '#default_value' => $config
      ->get('pattern'),
    '#description' => $this
      ->t('Enter the domains you wish to restrict registration. One entry per line in the format (e.g. something.com). Wildcards are also supported (e.g. *.something.com) to match any subdomain.'),
  ];
  $form['message'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Error message'),
    '#default_value' => $config
      ->get('message'),
    '#description' => $this
      ->t('Enter the error message you want the user to see if the email address does not validate.'),
  ];
  return parent::buildForm($form, $form_state);
}