function PluginBase::globalTokenForm

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::globalTokenForm()
  2. 8.9.x core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::globalTokenForm()
  3. 11.x core/modules/views/src/Plugin/views/PluginBase.php \Drupal\views\Plugin\views\PluginBase::globalTokenForm()

Overrides ViewsPluginInterface::globalTokenForm

3 calls to PluginBase::globalTokenForm()
TestExample::buildOptionsForm in core/modules/views/tests/modules/views_test_data/src/Plugin/views/area/TestExample.php
Provide a form to edit options for this plugin.
Title::buildOptionsForm in core/modules/views/src/Plugin/views/area/Title.php
Provide a form to edit options for this plugin.
TokenizeAreaPluginBase::tokenForm in core/modules/views/src/Plugin/views/area/TokenizeAreaPluginBase.php
Adds tokenization form elements.

File

core/modules/views/src/Plugin/views/PluginBase.php, line 458

Class

PluginBase
Base class for any views plugin types.

Namespace

Drupal\views\Plugin\views

Code

public function globalTokenForm(&$form, FormStateInterface $form_state) {
    $token_items = [];
    foreach ($this->getAvailableGlobalTokens() as $type => $tokens) {
        $item = [
            '#markup' => $type,
            'children' => [],
        ];
        foreach ($tokens as $name => $info) {
            $item['children'][$name] = "[{$type}:{$name}]" . ' - ' . $info['name'] . ': ' . $info['description'];
        }
        $token_items[$type] = $item;
    }
    $form['global_tokens'] = [
        '#type' => 'details',
        '#title' => $this->t('Available global token replacements'),
    ];
    $form['global_tokens']['list'] = [
        '#theme' => 'item_list',
        '#items' => $token_items,
        '#attributes' => [
            'class' => [
                'global-tokens',
            ],
        ],
    ];
}

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