function webform_view_field_formatter_view in Webform view 7
Same name and namespace in other branches
- 7.4 webform_view.module \webform_view_field_formatter_view()
Insert a PLACEHOLDER value as the text rendering of an item.
The webform postprocess should replace this placeholder with the form element
Implements hook_field_formatter_view().
See also
File
- ./
webform_view.module, line 129 - Allows views to be embedded in webforms and used as submission data.
Code
function webform_view_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'webform_view_placeholder':
foreach ($items as $delta => $item) {
// Don't even insert the placeholder if there is no value in the trigger
// element.
if (!empty($item['value'])) {
$key = $entity_type == 'node' ? $entity->nid : $entity->id;
$replace_pattern = "[webform_view_" . $key . "_placeholder]";
$element[$delta] = array(
'#type' => 'markup',
'#markup' => $replace_pattern,
);
}
else {
// Cannot order, return empty string.
$element[$delta] = array(
'#type' => 'markup',
'#markup' => '',
);
}
}
break;
}
return $element;
}