You are here

public function UserRole::buildConfigurationForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/Condition/UserRole.php \Drupal\user\Plugin\Condition\UserRole::buildConfigurationForm()
  2. 9 core/modules/user/src/Plugin/Condition/UserRole.php \Drupal\user\Plugin\Condition\UserRole::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);
}