You are here

public function User::buildOptionsForm in Views (for Drupal 7) 8.3

Same name in this branch
  1. 8.3 lib/Views/user/Plugin/views/argument_default/User.php \Views\user\Plugin\views\argument_default\User::buildOptionsForm()
  2. 8.3 lib/Views/user/Plugin/views/argument_validator/User.php \Views\user\Plugin\views\argument_validator\User::buildOptionsForm()
  3. 8.3 lib/Views/user/Plugin/views/field/User.php \Views\user\Plugin\views\field\User::buildOptionsForm()

Provide the default form for setting options.

Overrides ArgumentValidatorPluginBase::buildOptionsForm

File

lib/Views/user/Plugin/views/argument_validator/User.php, line 38
Definition of Views\user\Plugin\views\argument_validator\User.

Class

User
Validate whether an argument is a valid user.

Namespace

Views\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_roles(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,
        ),
      ),
    ),
  );
}