1 field_ui.admin.inc _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode, &$settings)

Populates display settings for a new display mode from the default display mode.

When an administrator decides to use custom display settings for a display mode, that display mode needs to be initialized with the display settings for the 'default' display mode, which it was previously using. This helper function adds the new custom display settings to this bundle's instances, and saves them. It also modifies the passed-in $settings array, which the caller can then save using field_bundle_settings().


$entity_type: The bundle's entity type.

$bundle: The bundle whose display mode is being customized.

$view_mode: The display mode that the administrator has set to use custom settings.

$settings: An associative array of bundle settings, as expected by field_bundle_settings().

See also




core/modules/field_ui/field_ui.admin.inc, line 1468
Admin page callbacks for the Field UI module.


function _field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode, &$settings) {
  // Update display settings for field instances.
  $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle));
  foreach ($instances as $instance) {
    // If this field instance has display settings defined for this Display
    // mode, respect those settings.
    if (!isset($instance['display'][$view_mode])) {
      // The instance doesn't specify anything for this display mode, so use the
      // default display settings.
      $instance['display'][$view_mode] = $instance['display']['default'];

  // Update display settings for 'extra fields'.
  foreach (array_keys($settings['extra_fields']['display']) as $name) {
    if (!isset($settings['extra_fields']['display'][$name][$view_mode])) {
      $settings['extra_fields']['display'][$name][$view_mode] = $settings['extra_fields']['display'][$name]['default'];