'token_tree_link',
'#token_types' => array('jihad_flag'),
);
// Validation options to add to form elements.
$token_options = array(
'#element_validate' => array('token_element_validate'),
'#token_types' => array(),
'#min_tokens' => 1,
'#max_tokens' => 10,
);
// Let admin know that this field is now tokenized.
$form['messages']['flag_short']['#description'] .= '
' . t('This field supports tokens (try: "Jihad [flagcount:count]")');
$form['messages']['flag_short']['#suffix'] = render($browse_array);
$form['messages']['flag_short'] += $token_options;
$form['messages']['unflag_short']['#description'] .= '
' . t('This field supports tokens (try: "Truce [flagcount:count]")');
$form['messages']['unflag_short']['#suffix'] = render($browse_array);
$form['messages']['unflag_short'] += $token_options;
}
}
/**
* Implements hook_preprocess_HOOK().
*/
function jihad_flag_preprocess_flag(&$variables) {
// Replace the link title with any tokens.
$token = Drupal::token();
$variables['title'] = $token->replace($variables['title'], array(
'flag_id' => $variables['flag']->id(),
'entity_id' => $variables['flaggable']->id(),
));
}