function entityform_tokens in Entityform 7
Same name and namespace in other branches
- 7.2 entityform.tokens.inc \entityform_tokens()
Implements hook_tokens().
File
- ./
entityform.module, line 179 - Module for the Entityform Entity - a starting point to create your own Entity and associated administration interface
Code
function entityform_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
if ($type == 'entityform' && !empty($data['entityform'])) {
$entityform = $data['entityform'];
foreach ($tokens as $name => $original) {
switch ($name) {
case 'entityform-submittd-data':
$instances = field_info_instances('entityform', $entityform->type);
$view_mode = 'email';
$autofields = array();
foreach ($instances as $instance) {
$field_display = isset($instance['display'][$view_mode]) ? $instance['display'][$view_mode] : $instance['display']['default'];
// don't add to autofields if this field was hidden in the view mode
if ($field_display['type'] != 'hidden') {
$items = field_get_items('entityform', $entityform, $instance['field_name']);
if (!empty($items)) {
$autofields[$field_display['weight']] = array(
'field_name' => $instance['field_name'],
'options' => array(
'type' => $field_display['type'],
'settings' => $field_display['settings'],
),
);
$autofields[$field_display['weight']] = field_view_value('entityform', $entityform, $instance['field_name'], $items[0], $field_display);
$autofields[$field_display['weight']]['#title'] = $instance['label'];
}
}
}
// reorder fields to match view mode
ksort($autofields);
$replacements[$original] = theme('entityform_submittd_data', array(
'instances' => $instances,
'fields' => $autofields,
'entityform' => $entityform,
));
break;
}
}
}
return $replacements;
}