function UserData::buildOptionsForm

Same name and namespace in other branches
  1. 9 core/modules/user/src/Plugin/views/field/UserData.php \Drupal\user\Plugin\views\field\UserData::buildOptionsForm()
  2. 8.9.x core/modules/user/src/Plugin/views/field/UserData.php \Drupal\user\Plugin\views\field\UserData::buildOptionsForm()
  3. 10 core/modules/user/src/Plugin/views/field/UserData.php \Drupal\user\Plugin\views\field\UserData::buildOptionsForm()

Overrides FieldPluginBase::buildOptionsForm

File

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

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->moduleExtensionList
            ->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'],
    ];
}

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