function field_test_field_formatter_prepare_view

7.x field_test.field.inc field_test_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays)

Implements hook_field_formatter_prepare_view().

File

drupal-7.x/modules/field/tests/field_test.field.inc, line 349
Defines a field type and its formatters and widgets.

Code

function field_test_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
  foreach ($items as $id => $item) {
    // To keep the test non-intrusive, only act on the
    // 'field_test_with_prepare_view' formatter.
    if ($displays[$id]['type'] == 'field_test_with_prepare_view') {
      foreach ($item as $delta => $value) {
        // Don't add anything on empty values.
        if ($value) {
          $items[$id][$delta]['additional_formatter_value'] = $value['value'] + 1;
        }
      }
    }
  }
}