You are here

function token_form_action_form_alter in Token 8

Implements hook_form_BASE_FORM_ID_alter().

Alters the configure action form to add token context validation and adds the token tree for a better token UI and selection.

File

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

Code

function token_form_action_form_alter(&$form, $form_state) {
  if (isset($form['plugin'])) {
    switch ($form['plugin']['#value']) {
      case 'action_message_action':
      case 'action_send_email_action':
      case 'action_goto_action':
        $form['token_tree'] = [
          '#theme' => 'token_tree_link',
          '#token_types' => 'all',
          '#weight' => 100,
        ];
        $form['actions']['#weight'] = 101;

        // @todo Add token validation to the action fields that can use tokens.
        break;
    }
  }
}