You are here

public function UserData::buildOptionsForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/src/Plugin/views/field/UserData.php \Drupal\user\Plugin\views\field\UserData::buildOptionsForm()

Default options form that provides the label widget that all fields should have.

Overrides FieldPluginBase::buildOptionsForm

File

core/modules/user/src/Plugin/views/field/UserData.php, line 69

Class

UserData
Provides access to the user data service.

Namespace

Drupal\user\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $modules = $this->moduleHandler
    ->getModuleList();
  $names = [];
  foreach (array_keys($modules) as $name) {
    $names[$name] = $this->moduleHandler
      ->getName($name);
  }
  $form['data_module'] = [
    '#title' => $this
      ->t('Module name'),
    '#type' => 'select',
    '#description' => $this
      ->t('The module which sets this user data.'),
    '#default_value' => $this->options['data_module'],
    '#options' => $names,
  ];
  $form['data_name'] = [
    '#title' => $this
      ->t('Name'),
    '#type' => 'textfield',
    '#description' => $this
      ->t('The name of the data key.'),
    '#default_value' => $this->options['data_name'],
  ];
}