Index: bio.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bio/bio.module,v
retrieving revision 1.2.2.25
diff -u -p -r1.2.2.25 bio.module
--- bio.module	28 Jan 2008 08:30:13 -0000	1.2.2.25
+++ bio.module	20 Aug 2008 15:35:50 -0000
@@ -115,7 +115,7 @@ function bio_form_alter($form_id, &$form
     foreach ($fields as $field_name => $field) {
       if ($field['required'] || !empty($default_values[$field_name])) {
         $node_field = content_default_value($node, $field, array());
-      
+
         // Figure out what widget function to call.
         $module = $widget_types[$field['widget']['type']]['module'];
         $function = $module .'_widget';
@@ -124,7 +124,33 @@ function bio_form_alter($form_id, &$form
         $cck_field = $function('prepare form values', $node, $field, $node_field);
         $cck_field = $function('form', $node, $field, $node_field);
         $form = array_merge($form, $cck_field);
+        $form[$field_name]['#weight'] = $field['widget']['weight'];
+      }
+    }
 
+    // Group fields if fieldgroup cck module exists. This code is lifted almost verbatim from fieldgroup.
+    if (module_exists('fieldgroup')) {
+      $groups = _bio_get_groups();
+      foreach ($groups as $group) {
+        $form[$group['group_name']] = array(
+          '#type' => 'fieldset',
+          '#title' => t($group['label']),
+          '#collapsed' => $group['settings']['form']['style'] == 'fieldset_collapsed',
+          '#collapsible' => in_array($group['settings']['form']['style'], array('fieldset_collapsed', 'fieldset_collapsible')),
+          '#weight' => $group['weight'],
+          '#description' => t($group['settings']['form']['description']),
+          '#attributes' => array('class' => strtr($group['group_name'], '_', '-')),
+        );
+        foreach ($group['fields'] as $fn => $f) {
+          if (isset($form[$fn])) {
+            $form[$group['group_name']][$fn] = $form[$fn];
+            unset($form[$fn]);
+          }
+        }
+        if (!empty($group['fields']) && !element_children($form[$group_name])) {
+          //hide the fieldgroup, because the fields are hidden too
+          unset($form[$group_name]);
+        }
       }
     }
 
@@ -438,6 +464,14 @@ function _bio_get_fields() {
 }
 
 /**
+ * Retrieve group info for Bio CCK type.
+ */
+function _bio_get_groups() {
+  $bio_nodetype = bio_get_type();
+  return fieldgroup_groups($bio_nodetype, TRUE);
+}
+
+/**
  * Short-hand function to return bio node type.
  * 
  * @return $string
