public function PluginBase::globalTokenForm

Adds elements for available core tokens to a form.

Parameters

array $form: The form array to alter, passed by reference.

array $form_state: The form state array to alter, passed by reference.

3 calls to PluginBase::globalTokenForm()
AreaPluginBase::tokenForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/area/AreaPluginBase.php
Form helper function to add tokenization form elements.
TestExample::buildOptionsForm in drupal/core/modules/views/tests/views_test_data/lib/Drupal/views_test_data/Plugin/views/area/TestExample.php
Overrides Drupal\views\Plugin\views\area\AreaPluginBase::buildOptionsForm()
Title::buildOptionsForm in drupal/core/modules/views/lib/Drupal/views/Plugin/views/area/Title.php
Overrides Drupal\views\Plugin\views\AreaPluginBase::buildOptionsForm().

File

drupal/core/modules/views/lib/Drupal/views/Plugin/views/PluginBase.php, line 287
Definition of Drupal\views\Plugin\views\PluginBase.

Class

PluginBase

Namespace

Drupal\views\Plugin\views

Code

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