diff --git a/src/Element/TokenTreeTable.php b/src/Element/TokenTreeTable.php index 447c463..2b9a0a5 100644 --- a/src/Element/TokenTreeTable.php +++ b/src/Element/TokenTreeTable.php @@ -55,6 +55,11 @@ class TokenTreeTable extends Table { public static function preRenderTokenTree($element) { $multiple_token_types = count($element['#token_tree']) > 1; foreach ($element['#token_tree'] as $token_type => $type_info) { + // Do not show nested tokens. + if (!empty($type_info['nested']) && empty($element['#show_nested'])) { + continue; + } + if ($multiple_token_types) { $row = static::formatRow($token_type, $type_info, $element['#columns'], TRUE); $element['#rows'][] = $row; diff --git a/token.tokens.inc b/token.tokens.inc index 4742838..86a23cd 100644 --- a/token.tokens.inc +++ b/token.tokens.inc @@ -1241,6 +1241,7 @@ function field_token_info_alter(&$info) { 'name' => SafeMarkup::checkPlain($label), 'description' => t('@label tokens.', ['@label' => SafeMarkup::checkPlain($label)]), 'needs-data' => $field_token_name, + 'nested' => TRUE, ]; // Field list token type. if ($cardinality > 1) { @@ -1248,6 +1249,7 @@ function field_token_info_alter(&$info) { 'name' => t('List of @type values', array('@type' => SafeMarkup::checkPlain($label))), 'description' => t('Tokens for lists of @type values.', array('@type' => SafeMarkup::checkPlain($label))), 'needs-data' => "list<$field_token_name>", + 'nested' => TRUE, ); }