Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ChangeUserRoleBase.php

function ChangeUserRoleBase::buildConfigurationForm

Overrides PluginFormInterface::buildConfigurationForm

File

core/modules/user/src/Plugin/Action/ChangeUserRoleBase.php, line 61

Class

ChangeUserRoleBase
Provides a base class for operations to change a user's role.

Namespace

Drupal\user\Plugin\Action

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $roles = Role::loadMultiple();
    unset($roles[RoleInterface::ANONYMOUS_ID]);
    unset($roles[RoleInterface::AUTHENTICATED_ID]);
    $roles = array_map(fn(RoleInterface $role) => $role->label(), $roles);
    $form['rid'] = [
        '#type' => 'radios',
        '#title' => $this->t('Role'),
        '#options' => $roles,
        '#default_value' => $this->configuration['rid'],
        '#required' => TRUE,
    ];
    return $form;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal