Index: select_or_other.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/select_or_other/Attic/select_or_other.module,v
retrieving revision 1.1.2.1.2.10.2.5
diff -u -r1.1.2.1.2.10.2.5 select_or_other.module
--- select_or_other.module	5 Jan 2011 10:26:15 -0000	1.1.2.1.2.10.2.5
+++ select_or_other.module	19 Feb 2011 23:57:31 -0000
@@ -100,6 +100,11 @@
 
   );
 
+  // If working with checkboxes, set our own process function to handle them.
+  if ($element['#select_type'] == 'checkboxes') {
+    $element['select']['#process'] = array('select_or_other_expand_checkboxes');
+  }
+
   // Remove the default value on the container level so it doesn't get rendered there.
   $element['#value'] = NULL;
   // Remove the required parameter so FAPI doesn't force us to fill in the textfield.
@@ -205,6 +210,56 @@
 }
 
 /**
+ * Element process callback for Select (or other) checkboxes.
+ */
+function select_or_other_expand_checkboxes($element) {
+  $element = expand_checkboxes($element);
+  foreach (element_children($element) as $key) {
+    $element[$key]['#return_value'] = check_plain($element[$key]['#return_value']);
+    $element[$key]['#name'] = $element['#name'] . '[' . $element[$key]['#return_value'] . ']';
+    $element[$key]['#value_callback'] = 'select_or_other_checkbox_value';
+    $element[$key]['#pre_render'][] = 'select_or_other_checkbox_prerender';
+  }
+  return $element;
+}
+
+/**
+ * Helper function to determine the value for a checkbox form element.
+ *
+ * Drupal core cannot discern the difference between an unchecked checkbox and
+ * a checked checkbox that has a value of '0'. This value callback will return
+ * NULL instead of an integer 0 for checkboxes that are not checked.
+ *
+ * @see form_type_checkbox_value()
+ */
+function select_or_other_checkbox_value($form, $edit = FALSE) {
+  if ($edit !== FALSE) {
+    if (empty($form['#disabled'])) {
+      return $edit !== NULL ? $form['#return_value'] : NULL; // 0 in core.
+    }
+    else {
+      return $form['#default_value'];
+    }
+  }
+}
+
+/**
+ * Helper function to ensure that the default value of "0" checkboxes renders.
+ *
+ * The default handling of checkboxes only checks checkboxes based on the #value
+ * property. If a checkbox has a value of "0" (as a string), the checkbox
+ * doesn't print out the way it should.
+ *
+ * @see theme_checkbox()
+ */
+function select_or_other_checkbox_prerender($element) {
+  if ($element['#value'] === '0') {
+    $element['#value'] = TRUE;
+  }
+  return $element;
+}
+
+/**
  * Element validate callback for a Select (or other) element.
  */
 function select_or_other_element_validate($element, &$form_state) {
