public function User::buildOptionsForm

Same name in this branch
  1. 8.x drupal/core/modules/user/lib/Drupal/user/Plugin/views/field/User.php \Drupal\user\Plugin\views\field\User::buildOptionsForm()
  2. 8.x drupal/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
  3. 8.x drupal/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentValidatorPluginBase::buildOptionsForm

File

drupal/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php, line 38
Definition of Drupal\user\Plugin\views\argument_validator\User.

Class

User
Validate whether an argument is a valid user.

Namespace

Drupal\user\Plugin\views\argument_validator

Code

public function buildOptionsForm(&$form, &$form_state) {
  $form['type'] = array(
    '#type' => 'radios',
    '#title' => t('Type of user filter value to allow'),
    '#options' => array(
      'uid' => t('Only allow numeric UIDs'),
      'name' => t('Only allow string usernames'),
      'either' => t('Allow both numeric UIDs and string usernames'),
    ),
    '#default_value' => $this->options['type'],
  );
  $form['restrict_roles'] = array(
    '#type' => 'checkbox',
    '#title' => t('Restrict user based on role'),
    '#default_value' => $this->options['restrict_roles'],
  );
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Restrict to the selected roles'),
    '#options' => array_map('check_plain', user_role_names(TRUE)),
    '#default_value' => $this->options['roles'],
    '#description' => t('If no roles are selected, users from any role will be allowed.'),
    '#states' => array(
      'visible' => array(
        ':input[name="options[validate][options][user][restrict_roles]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
}