*** content_complete.orig.module	2011-04-05 13:50:00.000000000 -0400
--- content_complete.module	2011-04-08 09:50:31.000000000 -0400
***************
*** 144,149 ****
--- 144,154 ----
      form_set_error($fieldname, t('Please complete the fields.'));
    }
    
+   // Intercept all node forms and add a class to all fields that we're interested in
+   if (arg(1) == 'add' || (arg(2) == 'edit') && strpos($form_id, 'node_form') !== FALSE) {
+     $form['#after_build'][] = 'content_complete_after_build';
+   }
+   
    // Content type settings form
    if ($form_id == 'node_type_form' && user_access('access content complete')) {
      $form['content_complete'] = array(
***************
*** 201,206 ****
--- 206,248 ----
  }
  
  /**
+  * Manipulate the node for mafter CCK does its thing
+  */
+ function content_complete_after_build($form, &$form_state) {
+   $fields = variable_get('content_complete_fields_'. $form['type']['#value'], array());
+   
+   // use a recursive function to walk any possible fieldsets
+   // idea from http://drupal.org/node/726282#comment-2848294
+   content_complete_cck_walker($form, $fields);
+   
+   return $form;
+ }
+ 
+ /**
+  * Recursively walk a form tree and modify any fields we're interested in
+  */
+ function content_complete_cck_walker(&$tree, &$fields) {
+   foreach($tree as $key => &$value) {
+     if (is_array($value)) {
+       if ($value['#type'] == 'fieldset') {
+        //call this function again recursively
+        content_complete_cck_walker($value, $fields);
+       }
+       elseif (in_array($key, $fields)) {
+         if (isset($value['#type']) && $value['#type'] == 'optionwidgets_buttons') {
+           $value['value']['#prefix'] = $value['value']['#prefix'] . '<div class="content_complete">';
+           $value['value']['#suffix'] = '</div>' . $value['value']['#suffix'];
+         }
+         else {
+           $value[0]['#prefix'] = $value[0]['#prefix'] . '<div class="content_complete">';
+           $value[0]['#suffix'] = '</div>' . $value[0]['#suffix'];
+         }
+       }
+     }
+   }
+ }
+ 
+ /**
   * Submit function called when a node type is deleted. Remove the node type from
   * the content_complete table as well.
   * 
