You are here

public function RoleBasedGlobalText::buildOptionsForm in Views Role Based Global Text 8

Same name and namespace in other branches
  1. 8.2 src/RoleBasedGlobalText.php \Drupal\views_role_based_global_text\RoleBasedGlobalText::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides Text::buildOptionsForm

File

src/RoleBasedGlobalText.php, line 25

Class

RoleBasedGlobalText
Class RoleBasedGlobalText.

Namespace

Drupal\views_role_based_global_text

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['roles_fieldset'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Roles'),
  ];
  $form['roles_fieldset']['roles'] = [
    '#title' => $this
      ->t('Select Roles'),
    '#type' => 'checkboxes',
    '#options' => user_role_names(),
    '#default_value' => $this->options['roles_fieldset']['roles'] ?? [],
    '#description' => $this
      ->t('Only the checked roles will be able to access this value. If no role is selected, available to all.'),
  ];
}