function physical_field_formatter_view in Physical Fields 7
Implements hook_field_formatter_view().
File
- ./
physical.module, line 516 - Defines fields (e.g. weight and dimensions) to support describing the physical attributes of entities.
Code
function physical_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$settings = array_merge(field_info_formatter_settings($display['type']), $display['settings']);
$element = array();
// Loop through each item in this field.
foreach ($items as $delta => $item) {
// Generate the HTML based on the formatter.
switch ($display['type']) {
case 'physical_volume_formatted':
$html = physical_volume_format($item);
break;
case 'physical_weight_formatted':
$html = physical_weight_format($item);
break;
case 'physical_dimensions_formatted':
$html = physical_dimensions_format($item);
break;
}
// Add the link to the returned element array.
$element[$delta] = array(
'#markup' => $html,
);
}
return $element;
}