public function User::buildOptionsForm in Drupal 10
Same name in this branch
- 10 core/modules/user/src/Plugin/views/argument_default/User.php \Drupal\user\Plugin\views\argument_default\User::buildOptionsForm()
- 10 core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
Same name and namespace in other branches
- 8 core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
- 9 core/modules/user/src/Plugin/views/argument_validator/User.php \Drupal\user\Plugin\views\argument_validator\User::buildOptionsForm()
Overrides Entity::buildOptionsForm
1 call to User::buildOptionsForm()
- UserName::buildOptionsForm in core/
modules/ user/ src/ Plugin/ views/ argument_validator/ UserName.php
1 method overrides User::buildOptionsForm()
- UserName::buildOptionsForm in core/
modules/ user/ src/ Plugin/ views/ argument_validator/ UserName.php
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_validatorCode
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,
],
],
],
];
}