Index: checkbox_validate.module
===================================================================
--- checkbox_validate.module	(revision 613)
+++ checkbox_validate.module	(working copy)
@@ -1,68 +1,42 @@
 <?php
-// $Id: checkbox_validate.module,v 1.2.2.2 2008/08/23 22:03:05 MegaGrunt Exp $  
+// $Id: checkbox_validate.module,v 1.2.2.2 2008/08/23 22:03:05 MegaGrunt Exp $
 
 /**
  * Implementation of hook_menu().
  */
 function checkbox_validate_menu($may_cache) {
-	$items = array();
-
-	if (!$may_cache) {
-		drupal_add_css(drupal_get_path('module', 'checkbox_validate') .'/checkbox_validate.css'); 
-	}
-	return $items;
+  $items = array();
+  if (!$may_cache) {
+    drupal_add_css(drupal_get_path('module', 'checkbox_validate') . '/checkbox_validate.css');
+  }
+  return $items;
 }
 
-
 /**
- * Implementation of hook_form_alter().
+ * Implementation of hook_elements().
  */
-function checkbox_validate_form_alter($form_id, &$form) {
-  $form = checkbox_validate_recurse($form); 
-  return; 
+function checkbox_validate_elements() {
+  $type['checkbox'] = array('#process' => array('checkbox_validate_add_validation' => array()));
+  return $type;
 }
 
 /**
- * Recurse through a form array to find required checkboxes
+ * Process function for checkbox form elements.
  */
-function checkbox_validate_recurse($form_item) {
-  if (!is_array($form_item)) return;
-
-  foreach ($form_item as $key => $value) {
-
-    if (strpos($key, '#') === 0) {
-
-      if (isset($form_item['#type']) && $form_item['#type'] == 'checkbox' && isset($form_item['#required']) && $form_item['#required'] == TRUE) {
-         
-        $form_item['#validate']['checkbox_validate_validation'] = array();
-        $form_item['#title'] .= '<span class="form-required" title="' . t('This field is required.') . '"> *</span>';  
-        return $form_item;
-      }
-      
-    }
-    else {
-
-      $form_item[$key] = checkbox_validate_recurse($value, $key);
-    }
+function checkbox_validate_add_validation($element) {
+  if (isset($element['#required']) && $element['#required'] == TRUE) {
+    $element['#validate']['checkbox_validate_validation'] = array();
+    $element['#title'] .= ' <span class="form-required" title="' . t('This field is required.') . '">*</span>';
   }
-
-  return $form_item;
-}
-
-
-/* validate a required checkbox */
-function checkbox_validate_validation($element) { 
-  if (empty($element['#value'])) form_error($element, t('!title field is required.', array('!title' => filter_xss_admin(($element['#title'])))));
-  return;
+  return $element;
 }
 
 /**
- * Implementation of hook_theme().
+ * Validate a required checkbox.
  */
-function checkbox_validate_theme() {
-  return array(
-    'checkbox_validate_required' => array(
-      'arguments' => array(),
-    ),
-  );
+function checkbox_validate_validation($element) {
+  if (empty($element['#value'])) {
+    form_error($element, t('!title field is required.', array('!title' => filter_xss_admin($element['#title']))));
+  }
 }
+
