summaryrefslogtreecommitdiff
path: root/modules/field/field.info.inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field/field.info.inc')
-rw-r--r--modules/field/field.info.inc27
1 files changed, 17 insertions, 10 deletions
diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc
index f435d99a6..c3b29573f 100644
--- a/modules/field/field.info.inc
+++ b/modules/field/field.info.inc
@@ -24,6 +24,8 @@
* are affected.
*/
function field_info_cache_clear() {
+ drupal_static_reset('field_view_mode_settings');
+
// @todo: Remove this when field_attach_*_bundle() bundle management
// functions are moved to the entity API.
entity_info_cache_clear();
@@ -273,7 +275,7 @@ function _field_info_prepare_field($field) {
* Prepares an instance definition for the current run-time context.
*
* Since the instance was last saved or updated, a number of things might have
- * changed: widgets or formatters disabled, new settings expected, new build
+ * changed: widgets or formatters disabled, new settings expected, new view
* modes added...
*
* @param $instance
@@ -301,16 +303,21 @@ function _field_info_prepare_instance($instance, $field) {
$instance['display'][$view_mode] = _field_info_prepare_instance_display($field, $display);
}
- // Fallback to 'hidden' for unspecified view modes.
+ // Fallback to 'hidden' for view modes configured to use custom display
+ // settings, and for which the instance has no explicit settings.
$entity_info = entity_get_info($instance['entity_type']);
- foreach ($entity_info['view modes'] as $view_mode => $info) {
- if (!isset($instance['display'][$view_mode])) {
- $instance['display'][$view_mode] = array(
- 'type' => 'hidden',
- 'label' => 'above',
- 'settings' => array(),
- 'weight' => 0,
- );
+ $view_modes = array_merge(array('default'), array_keys($entity_info['view modes']));
+ $view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
+ foreach ($view_modes as $view_mode) {
+ if ($view_mode == 'default' || !empty($view_mode_settings[$view_mode]['custom_settings'])) {
+ if (!isset($instance['display'][$view_mode])) {
+ $instance['display'][$view_mode] = array(
+ 'type' => 'hidden',
+ 'label' => 'above',
+ 'settings' => array(),
+ 'weight' => 0,
+ );
+ }
}
}