Commit 212aca6b authored by Mike Keran's avatar Mike Keran
Browse files

Issue #2655788 by mikeker: Allow token replacements in description field

parent 1d8aaefc
......@@ -62,18 +62,32 @@ function better_exposed_filters_theme($existing, $type, $theme, $path) {
function better_exposed_filters_form_views_ui_config_item_form_alter(&$form, FormStateInterface $form_state) {
// Checks if Token module is enabled.
if (!\Drupal::moduleHandler()->moduleExists('token')) {
$text = t('Enable the Token module to allow token replacement in this field.');
if (empty($form['options']['expose']['description']['#description'])) {
$form['options']['expose']['description']['#description'] = $text;
}
else {
$form['options']['expose']['description']['#description'] .= " $text";
}
return;
}
// Adds global token replacements, if available.
$form['options']['expose']['global_replacement_tokens'] = array(
$text = t('Tokens are allowed in this field. Replacement options can be found in the "Global replacement patterns" section, below.');
if (empty($form['options']['expose']['description']['#description'])) {
$form['options']['expose']['description']['#description'] = $text;
}
else {
$form['options']['expose']['description']['#description'] .= " $text";
}
$form['options']['expose']['global_replacement_tokens'] = [
'#title' => t('Global replacement patterns (for description field only)'),
'#type' => 'details',
'#weight' => 151,
);
$form['options']['expose']['global_replacement_tokens']['list'] = array(
];
$form['options']['expose']['global_replacement_tokens']['list'] = [
'#theme' => 'token_tree_link',
'#token_types' => array(),
);
'#token_types' => [],
];
}
/******************************************************************************
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment