--- C:/Downloads/Web/Drupal/Modules/conditional_fields-6.x-2.x-dev/conditional_fields/conditional_fields.module	Mon Oct 11 13:35:05 2010
+++ C:/Applications/web/wamp/www/isi6/modules/conditional_fields/conditional_fields.module	Mon Oct 11 15:12:52 2010
@@ -201,20 +201,23 @@
     if (user_access('administer conditional fields') && variable_get('c_fields_show_all_' . $type['type'], 0)) {
       return;
     }
-
+	// Get all groups from form
+	$groups =   fieldgroup_groups($node->type);
     foreach ($data as $field) {
 
       // We might have to look for the field in a group
       $controlled_group = conditional_fields_get_group($node->type, $field['field_name']);
+	  $controlled_group_ref = conditional_fields_get_item_group($groups, $controlled_group, $node->content);
       $controlling_group = conditional_fields_get_group($node->type, $field['control_field_name']);
-
+	  // Get group array of the form
+	  $controlling_group_ref = conditional_fields_get_item_group($groups, $controlling_group, $node->content);
       // The controlled field is not in a group and is not in the form for other reasons. Skip.
       if (!$controlled_group && !$node->content[$field['field_name']]) {
         continue;
       }
 
       // The controlled field is in a group and is not the form for other reasons. Skip.
-      if ($controlled_group && !$node->content[$controlled_group]['group'][$field['field_name']]) {
+      if ($controlled_group && !$controlled_group_ref[$field['field_name']]) {
         continue;
       }
 
@@ -226,9 +229,9 @@
       $field_key = array_keys($type['fields'][$field['control_field_name']]['columns']);
       foreach ((array)$node->$field['control_field_name'] as $value) {
         $current_values[$field['control_field_name']][] = $value[$field_key[0]];
-        if (!empty($value[$field_key[0]])) {
+        if ($value[$field_key[0]] != "") {
           if ($node->content[$field['control_field_name']]['field']['#access'] == TRUE ||
-              ($controlling_group && $node->content[$controlling_group]['group'][$field['control_field_name']]['field']['#access'] == TRUE)) {
+              ($controlling_group && $controlling_group_ref[$field['control_field_name']]['field']['#access'] == TRUE)) {
             $viewed = TRUE;
           }
         }
@@ -238,10 +240,11 @@
         // Hide the controlled field if it is not triggered
         if (!conditional_fields_is_triggered($current_values[$field['control_field_name']], $field['trigger_values'])) {
           if ($controlled_group) {
-            $node->content[$controlled_group]['group'][$field['field_name']]['#access'] = FALSE;
+			conditional_fields_hide_field_node_viewing($groups, $controlled_group, $node->content, $field['field_name']);
+			
           }
           else {
-            $node->content[$field['field_name']]['#access'] = FALSE;
+            $node->content[$field['field_name']]['field']['#access'] = FALSE;
           }
         }
       }
@@ -894,8 +894,8 @@
     }
   }
   else {
-    if ($haystack[$item_name]) {
-      $items[$item_name] = $haystack[$item_name];
+    if ($form[$item_name]) {
+      $items[$item_name] = $form[$item_name];
     }
     elseif ($haystack[$form['#field_info'][$item_name]['display_settings']['parent']][$item_name]) {
       $items[$item_name] = $haystack[$form['#field_info'][$item_name]['display_settings']['parent']][$item_name];
@@ -1441,3 +1441,38 @@
   $id = str_replace(array('][', '_', ' '), '-', $id);
   return $id;
 }
+
+/**
+* Retuns group array from a name
+*/
+function conditional_fields_get_item_group($groups, $group_name, $content) {
+	  $group = $group_name;
+	  $group_chain = array();
+	  while ($group != "") {
+		  array_unshift($group_chain, $group);
+		  $group = $groups[$group]["parent_group_name"];
+	  }
+	  $groupref = &$content;
+	  foreach ($group_chain as $group) {
+		$groupref = &$groupref[$group]['group'];
+	  }
+	return $groupref;
+}
+
+/**
+* Hides field within a group or nested group
+*/
+
+function conditional_fields_hide_field_node_viewing($groups, $group_name, &$content, $field_name) {
+	  $group = $group_name;
+	  $group_chain = array();
+	  while ($group != "") {
+		  array_unshift($group_chain, $group);
+		  $group = $groups[$group]["parent_group_name"];
+	  }
+	  $groupref = &$content;
+	  foreach ($group_chain as $group) {
+		$groupref = &$groupref[$group]['group'];
+	  }
+	  $groupref[$field_name]['field']['#access'] = FALSE;
+}
