function background_image_formatter_token_settings_form in Simple Background image formatter 7
Add tokens to settings form.
1 call to background_image_formatter_token_settings_form()
File
- ./
background_image_formatter.helpers.inc, line 26 - Helpers for module.
Code
function background_image_formatter_token_settings_form($field, &$element) {
$tokens_mapping = token_get_entity_mapping();
$entity_types = array_keys($field['bundles']);
$tokens_list = array();
foreach ($tokens_mapping as $token_map => $entity_map) {
foreach ($entity_types as $entity_type) {
if ($entity_type == $entity_map) {
$tokens_list[] = $token_map;
}
}
}
$element['background_image_token']['tokens'] = array(
'#type' => 'fieldset',
'#title' => t('Available tokens'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$element['background_image_token']['tokens']['list'] = array(
'#theme' => 'token_tree',
'#token_types' => $tokens_list,
'#global_types' => TRUE,
'#click_insert' => TRUE,
);
}