_field_info_prepare_instance_display

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 _field_info_prepare_instance_display($field, $display)

Adapts display specifications to the current run-time context.

Parameters

$field The field structure for the instance.

$display Display specifications as found in $instance['display']['some_view_mode'].

Related topics

▾ 2 functions call _field_info_prepare_instance_display()

field_view_field in modules/field/field.module
Returns a renderable array for the value of a single field in an entity.
_field_info_prepare_instance in modules/field/field.info.inc
Prepares an instance definition for the current run-time context.

Code

modules/field/field.info.inc, line 344

<?php
function _field_info_prepare_instance_display($field, $display) {
  $field_type = field_info_field_types($field['type']);

  // Fill in default values.
  $display += array(
    'label' => 'above', 
    'type' => $field_type['default_formatter'], 
    'settings' => array(), 
    'weight' => 0,
  );
  if ($display['type'] != 'hidden') {
    $formatter_type = field_info_formatter_types($display['type']);
    // Fallback to default formatter if formatter type is not available.
    if (!$formatter_type) {
      $display['type'] = $field_type['default_formatter'];
      $formatter_type = field_info_formatter_types($display['type']);
    }
    $display['module'] = $formatter_type['module'];
    // Fill in default settings for the formatter.
    $display['settings'] += field_info_formatter_settings($display['type']);
  }

  return $display;
}
?>