diff -upr ../conditional_fields/conditional_fields.module conditional_fields/conditional_fields.module
--- ../conditional_fields/conditional_fields.module     2009-11-27 07:01:47.000000000 +1000
+++ conditional_fields/conditional_fields.module        2009-11-27 11:40:06.000000000 +1000
@@ -317,7 +317,7 @@ function conditional_fields_form_alter(&
   }

   if (isset($form['type']['#value']) && $form_id == $form['type']['#value'] . '_node_form') {
-    conditional_fields_node_editing_form($form, $form_state);
+    $form['#after_build'][] = 'conditional_fields_node_editing_form';
   }
 }

@@ -536,12 +536,12 @@ function conditional_fields_forms_submit
 /**
  * Alteration of the node editing form
  */
-function conditional_fields_node_editing_form(&$form, $form_state) {
+function conditional_fields_node_editing_form($form, $form_state) {
   $type_name = $form['type']['#value'];

   // Do nothing if there are no conditional fields
   if (!$data = conditional_fields_load_data($type_name)) {
-    return;
+    return $form;
   }

   // Remove from data fields that user can't edit
@@ -600,7 +600,7 @@ function conditional_fields_node_editing

   // Data could be empty by now
   if (empty($data)) {
-    return;
+    return $form;
   }

   // We build a javascript variable:
@@ -621,6 +621,7 @@ function conditional_fields_node_editing
   // We will check triggered fields in a custom validation form.
   // Here we also add enclosing divs for easier javascript handling to controlling fields and to controlled fields and groups
   $required_fields = array();
+  $form['#conditional_date_fields'] = array();

   foreach (element_children($form) as $element) {
     // Fields
@@ -639,6 +640,16 @@ function conditional_fields_node_editing
         }
         $form[$element]['#controlled_field'] = $element;
         $form[$element]['#theme'] = array('conditional_fields_form_item');
+
+        $form['#conditional_controlled_fields'][$element] = $form[$element];
+        $form['#conditional_controlled_fields_ref'][$element] =& $form[$element];
+
+        // Make special controlled date fields available in the validate routine.
+        if (!empty($form_state['submitted']) && $form['#field_info'][$form[$element]['#field_name']]['widget']['module'] == 'date') {
+          // Make sure the actual element does not get validated on its first pass.
+          // We validate it ourselves later.
+          _conditional_fields_set_validated($form[$element]);
+        }
       }
     }
     else if (strpos($element , 'group_') === 0) {
@@ -673,6 +684,16 @@ function conditional_fields_node_editing
           }
           $form[$element][$group_element]['#controlled_field'] = $group_element;
           $form[$element][$group_element]['#theme'] = array('conditional_fields_form_item');
+
+          $form['#conditional_controlled_fields'][$group_element] = $form[$element][$group_element];
+          $form['#conditional_controlled_fields_ref'][$group_element] =& $form[$element][$group_element];
+
+          // Make special controlled date fields available in the validate routine.
+          if (!empty($form_state['submitted']) && $form['#field_info'][$form[$element][$group_element]['#field_name']]['widget']['module'] == 'date') {
+            // Make sure the actual element does not get validated on its first pass.
+            // We validate it ourselves later.
+            _conditional_fields_set_validated($form[$element][$group_element]);
+          }
         }
       }
     }
@@ -701,6 +722,18 @@ function conditional_fields_node_editing

   // Add extra validation function
   $form['#validate'] = array_merge(array('conditional_fields_node_editing_form_validate'), (array)$form['#validate']);
+
+  return $form;
+}
+
+/**
+ * Recusively set the date fields as validated.
+ */
+function _conditional_fields_set_validated(&$elements) {
+  $elements['#validated'] = TRUE;
+  foreach (element_children($elements) as $key) {
+    _conditional_fields_set_validated($elements[$key]);
+  }
 }

 /**
@@ -755,11 +788,63 @@ function conditional_fields_node_editing
       }
       else {
         // Do not submit values of controlled fields which were not triggered (except on preview)
-        if (variable_get('c_fields_reset_default_' . $form['type']['#value'], 1) &&
-          !in_array('node_form_build_preview', $form_state['submit_handlers']) &&
-          is_array($form['#field_info'][$row['field_name']]['widget']['default_value'])) {
-          foreach ($form['#field_info'][$row['field_name']]['widget']['default_value'] as $delta => $value) {
-            $form_state['values'][$row['field_name']][$delta]['value'] = $value['value'];
+        if (variable_get('c_fields_reset_default_' . $form['type']['#value'], 1) && (!is_array($form_state['submit_handlers'])) || !in_array('node_form_build_preview', $form_state['submit_handlers'])) {
+          $field = $form['#field_info'][$row['field_name']];
+          $items = array();
+          if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
+            // If a module wants to insert custom default values here,
+            // it should provide a hook_default_value() function to call,
+            // otherwise the content module's content_default_value() function
+            // will be used.
+            $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
+            if (function_exists($callback)) {
+              $items = $callback($form, $form_state, $field, 0);
+            }
+            elseif ($field['widget']['module'] == 'date') {
+              // The date module is a special case, and if there is no callback, we need to construct the
+              // real default value ourselves.
+
+              $process = date_process_values($field);
+              foreach ($process as $processed) {
+                if (!isset($items[0][$processed])) {
+                  $items[0][$processed] = '';
+                }
+                $date = date_local_date($form, $form_state, 0, $items[0], date_default_timezone_name(), $field, $processed);
+                $items[0][$processed] = is_object($date) ? date_format($date, DATE_FORMAT_DATETIME) : '';
+              }
+            }
+          }
+          $form_state['values'][$row['field_name']] = $items;
+          // We now need to set the elements #value property, as this is what the date processing functions check.
+          _conditional_fields_set_date_value($form['#conditional_controlled_fields'][$row['field_name']], $form_state['values'][$row['field_name']]);
+          _conditional_fields_set_date_value($form['#conditional_controlled_fields_ref'][$row['field_name']], $form_state['values'][$row['field_name']]);
+        }
+      }
+
+      if ($form['#field_info'][$row['field_name']]['widget']['module'] == 'date') {
+        _form_validate($form['#conditional_date_fields'][$row['field_name']], $form_state);
+
+        // We need to check the field aggain now, as it's value should have changed.
+        if ($triggered) {
+
+          // Check required
+          if (!empty($required_fields) && $required_fields[$row['field_name']]) {
+
+            // Check if the controlled field is empty
+            if (conditional_fields_check_empty($form_state['values'][$row['field_name']])) {
+
+              // Check whether the controlled field is in a group or not and set error accordingly
+              if (!isset($required_fields[$row['field_name']]['in_group'])) {
+                form_error($form[$row['field_name']],
+                  t('!name field is required.',
+                  array('!name' => $form[$row['field_name']]['#title'])));
+              }
+              else {
+                form_error($form[$required_fields[$row['field_name']]['in_group']][$row['field_name']],
+                  t('!name field is required.',
+                  array('!name' => $form[$required_fields[$row['field_name']]['in_group']][$row['field_name']]['#title'])));
+              }
+            }
           }
         }
       }
@@ -786,11 +871,63 @@ function conditional_fields_node_editing
         }
         else {
           // Do not submit values of controlled fields which were not triggered (except on preview)
-          if (variable_get('c_fields_reset_default_' . $form['type']['#value'], 1) &&
-            !in_array('node_form_build_preview', $form_state['submit_handlers']) &&
-            is_array($form['#field_info'][$field_in_group]['widget']['default_value'])) {
-            foreach ($form['#field_info'][$field_in_group]['widget']['default_value'] as $delta => $value) {
-              $form_state['values'][$field_in_group][$delta]['value'] = $value['value'];
+          if (variable_get('c_fields_reset_default_' . $form['type']['#value'], 1) && (!is_array($form_state['submit_handlers'])) || !in_array('node_form_build_preview', $form_state['submit_handlers'])) {
+            $field = $form['#field_info'][$field_in_group];
+            $items = array();
+            if (content_callback('widget', 'default value', $field) != CONTENT_CALLBACK_NONE) {
+              // If a module wants to insert custom default values here,
+              // it should provide a hook_default_value() function to call,
+              // otherwise the content module's content_default_value() function
+              // will be used.
+              $callback = content_callback('widget', 'default value', $field) == CONTENT_CALLBACK_CUSTOM ? $field['widget']['module'] .'_default_value' : 'content_default_value';
+              if (function_exists($callback)) {
+                $items = $callback($form, $form_state, $field, 0);
+              }
+              elseif ($field['widget']['module'] == 'date') {
+                // The date module is a special case, and if there is no callback, we need to construct the
+                // real default value ourselves.
+
+                $process = date_process_values($field);
+                foreach ($process as $processed) {
+                  if (!isset($items[0][$processed])) {
+                    $items[0][$processed] = '';
+                  }
+                  $date = date_local_date($form, $form_state, 0, $items[0], date_default_timezone_name(), $field, $processed);
+                  $items[0][$processed] = is_object($date) ? date_format($date, DATE_FORMAT_DATETIME) : '';
+                }
+              }
+            }
+            $form_state['values'][$row['field_name']] = $items;
+            // We now need to set the elements #value property, as this is what the date processing functions check.
+            _conditional_fields_set_date_value($form['#conditional_controlled_fields'][$row['field_name']], $form_state['values'][$row['field_name']]);
+            _conditional_fields_set_date_value($form['#conditional_controlled_fields_ref'][$row['field_name']], $form_state['values'][$row['field_name']]);
+          }
+        }
+
+        if ($form['#field_info'][$row['field_name']]['widget']['module'] == 'date') {
+          _form_validate($form['#conditional_date_fields'][$row['field_name']], $form_state);
+
+          // We need to check the field aggain now, as it's value should have changed.
+          if ($triggered) {
+
+            // Check required
+            if (!empty($required_fields) && $required_fields[$row['field_name']]) {
+
+              // Check if the controlled field is empty
+              if (conditional_fields_check_empty($form_state['values'][$row['field_name']])) {
+
+                // Check whether the controlled field is in a group or not and set error accordingly
+                if (!isset($required_fields[$row['field_name']]['in_group'])) {
+                  form_error($form[$row['field_name']],
+                    t('!name field is required.',
+                    array('!name' => $form[$row['field_name']]['#title'])));
+                }
+                else {
+                  form_error($form[$required_fields[$row['field_name']]['in_group']][$row['field_name']],
+                    t('!name field is required.',
+                    array('!name' => $form[$required_fields[$row['field_name']]['in_group']][$row['field_name']]['#title'])));
+                }
+              }
             }
           }
         }
@@ -800,6 +937,25 @@ function conditional_fields_node_editing
 }

 /**
+ * Set the value for date fields.
+ */
+function _conditional_fields_set_date_value(&$element, $value) {
+  if (is_scalar($value) xor is_scalar($element['#value'])) {
+    $element['#value'] = $value;
+  }
+
+  foreach (element_children($element) as $key) {
+    if (!isset($value[$key])) {
+      $val = NULL;
+    }
+    else {
+      $val = $value[$key];
+    }
+    _conditional_fields_set_date_value($element[$key], $val);
+  }
+}
+
+/**
  * Checks if a submitted field value is empty
  */
 function conditional_fields_check_empty($field) {