summaryrefslogtreecommitdiff
path: root/modules/field
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field')
-rw-r--r--modules/field/field.info.inc27
-rw-r--r--modules/field/field.module8
2 files changed, 23 insertions, 12 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,
+ );
+ }
}
}
diff --git a/modules/field/field.module b/modules/field/field.module
index 823b0f24c..d3545d911 100644
--- a/modules/field/field.module
+++ b/modules/field/field.module
@@ -369,7 +369,7 @@ function _field_sort_items_value_helper($a, $b) {
* 'extra_field_2' => ...
* ),
* ),
- * ),
+ * );
* @endcode
*
* @param $entity_type
@@ -387,8 +387,8 @@ function field_bundle_settings($entity_type, $bundle, $settings = NULL) {
if (isset($settings)) {
$stored_settings[$entity_type][$bundle] = $settings;
+
variable_set('field_bundle_settings', $stored_settings);
- drupal_static_reset('field_view_mode_settings');
field_info_cache_clear();
}
else {
@@ -397,6 +397,10 @@ function field_bundle_settings($entity_type, $bundle, $settings = NULL) {
'view_modes' => array(),
'extra_fields' => array(),
);
+ $settings['extra_fields'] += array(
+ 'form' => array(),
+ 'display' => array(),
+ );
return $settings;
}