You are here

function token_form_block_form_alter in Token 8

Implements hook_form_FORM_ID_alter().

File

./token.module, line 93
Enhances the token API in core: adds a browseable UI, missing tokens, etc.

Code

function token_form_block_form_alter(&$form, FormStateInterface $form_state) {
  $token_tree = [
    '#theme' => 'token_tree_link',
    '#token_types' => [],
  ];
  $rendered_token_tree = \Drupal::service('renderer')
    ->render($token_tree);
  $form['settings']['label']['#description'] = t('This field supports tokens. @browse_tokens_link', [
    '@browse_tokens_link' => $rendered_token_tree,
  ]);
  $form['settings']['label']['#element_validate'][] = 'token_element_validate';
  $form['settings']['label'] += [
    '#token_types' => [],
  ];
}