You are here

function markup_field_formatter_prepare_view in Markup 7

Implements hook_field_formatter_prepare_view().

File

./markup.module, line 53
Defines a field type for displaying markup on the node/edit form.

Code

function markup_field_formatter_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items, $displays) {
  if ($field['type'] != 'markup') {
    return;
  }

  // Set item value to markup for all to-be-displayed markup.
  foreach ($items as $eid => $item) {
    $instance = $instances[$eid];
    if (in_array($instance['display']['default']['type'], array(
      'markup_view',
      'markup_display',
    ))) {

      // Add to display form in 'Always visible' and 'Display only' formatter.
      // Since markup is always a single item, add to the first item:
      $items[$eid][0]['markup'] = markup_translate_instance($field, $instance);
    }
  }
}