Index: options_element.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/options_element/options_element.inc,v
retrieving revision 1.10
diff -u -p -r1.10 options_element.inc
--- options_element.inc	29 Dec 2010 04:58:48 -0000	1.10
+++ options_element.inc	3 Feb 2011 22:14:36 -0000
@@ -8,11 +8,10 @@
 
 
 /**
- * Theme an options element.
+ * Pre render an options element
  */
-function theme_options($variables) {
-  $element = $variables['element'];
-
+function pre_render_options($element, $form_state) {
+  // Add classes to the class array.
   $classes = array();
   if (isset($element['#attributes']['class'])) {
     $classes = $element['#attributes']['class'];
@@ -32,41 +31,65 @@ function theme_options($variables) {
   if (isset($element['#multiple']) && $element['#multiple']) {
     $classes[] = 'options-multiple';
   }
+  $element['#attributes']['class'] = $classes;
+
+
+  $element['options'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Options'),
+    '#collapsible' => FALSE,
+    '#attributes' => array('class' => array('options')),
+  );
+
+  $element['options']['custom_keys'] = $element['options_field'];
+  unset($element['options_field']);
 
-  $options = '';
-  $options .= drupal_render($element['options_field']);
   if (isset($element['default_value_field'])) {
-    $options .= drupal_render($element['default_value_field']);
+    $element['options']['default_value_field'] = $element['default_value_field'];
+    unset($element['default_value_field']);
   }
 
-  $settings = '';
+  $element['settings'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Option settings'),
+    '#attributes' => array('class' => array('option-settings')),
+  );
+
+  $settings = array();
   if (isset($element['custom_keys'])) {
-    $settings .= drupal_render($element['custom_keys']);
+    $settings['custom_keys'] = $element['custom_keys'];
+    unset($element['custom_keys']);
   }
   if (isset($element['multiple'])) {
-    $settings .= drupal_render($element['multiple']);
+    $settings['multiple'] = $element['multiple'];
+    unset($element['multiple']);
   }
   if (isset($element['option_settings'])) {
-    $settings .= drupal_render($element['option_settings']);
+    $settings['option_settings'] = $element['option_settings'];
+    unset($element['option_settings']);
   }
 
-  $output = '';
-  $output .= '<div class="' . implode(' ', $classes) .'">';
-  $output .= theme('fieldset', array('element' => array(
-    '#title' => t('Options'),
-    '#collapsible' => FALSE,
-    '#children' => $options,
-    '#attributes' => array('class' => array('options')),
-  )));
-
-  if (!empty($settings)) {
-    $output .= theme('fieldset', array('element' => array(
+  if (count($settings) > 0) {
+    $element['settings'] = array(
+      '#type' => 'fieldset',
       '#title' => t('Option settings'),
-      '#collapsible' => FALSE,
-      '#children' => $settings,
       '#attributes' => array('class' => array('option-settings')),
-    )));
+    );
+    $element['settings'] = array_merge($element['settings'], $settings);
   }
+
+  return $element;
+}
+
+/**
+ * Theme an options element.
+ */
+function theme_options($variables) {
+  $element = $variables['element'];
+
+  $output = '';
+  $output .= '<div class="' . implode(' ', $element['#attributes']['class']) .'">';
+  $output .= drupal_render_children($element);
   $output .= '</div>';
 
   return $output;
Index: options_element.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/options_element/options_element.module,v
retrieving revision 1.7
diff -u -p -r1.7 options_element.module
--- options_element.module	5 Sep 2010 02:17:22 -0000	1.7
+++ options_element.module	3 Feb 2011 22:14:37 -0000
@@ -89,6 +89,7 @@ function options_element_element_info() 
     '#key_type_toggled' => FALSE,
     '#element_validate' => array('form_options_validate'),
     '#disabled' => FALSE,
+    '#pre_render' => array('pre_render_options'),
   );
 
   return $type;
