function User::buildOptionsForm

Same name in this branch
  1. 8.9.x core/modules/user/src/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::buildOptionsForm()
Same name in other branches
  1. 9 core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
  2. 9 core/modules/user/src/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::buildOptionsForm()
  3. 10 core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
  4. 10 core/modules/user/src/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::buildOptionsForm()
  5. 11.x core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
  6. 11.x core/modules/user/src/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::buildOptionsForm()

Overrides Entity::buildOptionsForm

1 call to User::buildOptionsForm()
UserName::buildOptionsForm in core/modules/user/src/Plugin/views/argument_validator/UserName.php
Provides the default form for setting options.
1 method overrides User::buildOptionsForm()
UserName::buildOptionsForm in core/modules/user/src/Plugin/views/argument_validator/UserName.php
Provides the default form for setting options.

File

core/modules/user/src/Plugin/views/argument_validator/User.php, line 51

Class

User
Validate whether an argument is a valid user.

Namespace

Drupal\user\Plugin\views\argument_validator

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']);
    $form['restrict_roles'] = [
        '#type' => 'checkbox',
        '#title' => $this->t('Restrict user based on role'),
        '#default_value' => $this->options['restrict_roles'],
    ];
    $form['roles'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Restrict to the selected roles'),
        '#options' => array_map([
            '\\Drupal\\Component\\Utility\\Html',
            'escape',
        ], user_role_names(TRUE)),
        '#default_value' => $this->options['roles'],
        '#description' => $this->t('If no roles are selected, users from any role will be allowed.'),
        '#states' => [
            'visible' => [
                ':input[name="options[validate][options][' . $sanitized_id . '][restrict_roles]"]' => [
                    'checked' => TRUE,
                ],
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.