You are here

public function AccessSettingsPageForm::buildForm in Multiple Registration 8.2

Same name and namespace in other branches
  1. 3.x src/Form/AccessSettingsPageForm.php \Drupal\multiple_registration\Form\AccessSettingsPageForm::buildForm()

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/AccessSettingsPageForm.php, line 91

Class

AccessSettingsPageForm
Class AccessSettingsPageForm.

Namespace

Drupal\multiple_registration\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('multiple_registration.access_settings_page_form_config');
  $form['multiple_registration_pages_white_list'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Multiple registration pages whitelist'),
    '#description' => $this
      ->t('Select multiple registration pages which will be accessible to anonymous user.'),
    '#default_value' => $config
      ->get('multiple_registration_pages_white_list'),
    '#options' => user_role_names(),
  ];

  // Hide authenticated and anonymous roles from the whitelist form to prevent
  // registration exceptions with service roles.
  $form['multiple_registration_pages_white_list']['anonymous'] = [
    '#access' => FALSE,
  ];
  $form['multiple_registration_pages_white_list']['authenticated'] = [
    '#access' => FALSE,
  ];
  $form['save'] = [
    '#type' => 'submit',
    '#attributes' => [
      'class' => [
        'button--primary',
      ],
    ],
    '#value' => $this
      ->t('Save access settings'),
  ];
  $form['do_nothing'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Cancel'),
  ];
  return $form;
}