Properly handle 'default' and customized view modes
authorYves Chedemois
Mon, 18 Oct 2010 23:02:04 +0000 (23:02 +0000)
committerYves Chedemois
Mon, 18 Oct 2010 23:02:04 +0000 (23:02 +0000)
modules/field_group/field_group.module

index bdf6db4..2181eba 100644 (file)
@@ -663,11 +663,6 @@ function field_group_info_groups($entity_type = NULL, $bundle = NULL, $view_mode
     if (isset($groups[$entity_type][$bundle][$view_mode])) {
       return $groups[$entity_type][$bundle][$view_mode];
     }
-    // @todo right assumption here ? (couldn't get anything else when looking at nodes
-    // unless I'd override the full content view mode also
-    elseif (isset($groups[$entity_type][$bundle]['default'])) {
-      return $groups[$entity_type][$bundle]['default'];
-    }
     else {
       return array();
     }
@@ -753,8 +748,13 @@ function field_group_field_attach_form($entity_type, $entity, &$form, &$form_sta
 /**
  * Implements hook_field_attach_view_alter().
  */
-function field_group_field_attach_view_alter(&$output, $context) {
-  field_group_attach_groups($output, $context['view_mode']);
+function field_group_field_attach_view_alter(&$element, $context) {
+  // Check whether the view mode uses custom display settings or the 'default'
+  // mode.
+  $view_mode_settings = field_view_mode_settings($element['#entity_type'], $element['#entity_type']);
+  $view_mode = $context['view_mode'];
+  $actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default');
+  field_group_attach_groups($element, $actual_mode);
 }
 
 /**