You are here

public function LegalAdminSettingsForm::buildForm in Legal 8

Same name and namespace in other branches
  1. 2.0.x src/Form/LegalAdminSettingsForm.php \Drupal\legal\Form\LegalAdminSettingsForm::buildForm()

Module settings form.

Overrides ConfigFormBase::buildForm

File

src/Form/LegalAdminSettingsForm.php, line 34

Class

LegalAdminSettingsForm
Class LegalAdminSettingsForm.

Namespace

Drupal\legal\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('legal.settings');
  $form['description'] = [
    '#markup' => '<p>' . $this
      ->t('Configuration options for display of Terms & Conditions.') . '</p>',
  ];
  $form['except_legal'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Exempt User Roles'),
    '#description' => $this
      ->t('Users with the selected roles will never be shown T&C.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  ];
  $role_options = user_role_names(TRUE);
  unset($role_options['authenticated']);
  $form['except_legal']['except_roles'] = [
    '#type' => 'checkboxes',
    '#title' => $this
      ->t('Exempt user roles'),
    '#options' => $role_options,
    '#default_value' => $config
      ->get('except_roles'),
    '#description' => $this
      ->t('Do not display Terms and Conditions check box for the selected user roles.'),
  ];
  $form['user_profile_display'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Show T&Cs on user profile edit pages'),
    '#default_value' => $config
      ->get('user_profile_display'),
  ];
  $form['accept_every_login'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Ask to accept T&Cs on every login'),
    '#default_value' => $config
      ->get('accept_every_login'),
  ];
  return parent::buildForm($form, $form_state);
}