function UserRole::buildConfigurationForm

Same name in other branches
  1. 8.9.x core/modules/user/src/Plugin/Condition/UserRole.php \Drupal\user\Plugin\Condition\UserRole::buildConfigurationForm()
  2. 10 core/modules/user/src/Plugin/Condition/UserRole.php \Drupal\user\Plugin\Condition\UserRole::buildConfigurationForm()
  3. 11.x core/modules/user/src/Plugin/Condition/UserRole.php \Drupal\user\Plugin\Condition\UserRole::buildConfigurationForm()

Overrides ConditionPluginBase::buildConfigurationForm

File

core/modules/user/src/Plugin/Condition/UserRole.php, line 24

Class

UserRole
Provides a 'User Role' condition.

Namespace

Drupal\user\Plugin\Condition

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form['roles'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('When the user has the following roles'),
        '#default_value' => $this->configuration['roles'],
        '#options' => array_map('\\Drupal\\Component\\Utility\\Html::escape', user_role_names()),
        '#description' => $this->t('If you select no roles, the condition will evaluate to TRUE for all users.'),
    ];
    return parent::buildConfigurationForm($form, $form_state);
}

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