? .svn
? ahah.patch
? cck_select_other-js.patch
? cck_select_other.js
? tests
Index: cck_select_other.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck_select_other/cck_select_other.module,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 cck_select_other.module
--- cck_select_other.module	17 Mar 2010 18:49:02 -0000	1.1.2.8
+++ cck_select_other.module	18 Mar 2010 19:59:27 -0000
@@ -55,6 +55,7 @@ function cck_select_other_elements() {
       '#delta' => 0,
       '#process' => array('cck_select_other_process'),
       '#pre_render' => array('cck_select_other_pre_render'),
+      '#post_render' => array('cck_select_other_post_render'),
       ),
     );
 }
@@ -79,6 +80,7 @@ function cck_select_other_widget(&$form,
   $element['select_other_list'] = array(
     '#type' => 'select',
     '#title' => $element['#field_name'],
+    '#description' => t('Select other to enter your own option.'),
     '#options' => $options,
     '#default_value' => $def,
   );
@@ -172,10 +174,20 @@ function cck_select_other_options($field
  * @return $form
  */
 function cck_select_other_pre_render($form) {
+  static $js;
 
   if (is_array($form['select_other_list'])) {
     return $form; 
   }
+
+  $field_name = substr($form['#field_name'], 6);
+
+  if (!$js) {
+    drupal_add_js(array('CCKSelectOther' => array('field' => $field_name)), 'setting');
+    drupal_add_js(drupal_get_path('module', 'cck_select_other').'/cck_select_other.js');
+    $js = TRUE;
+  }
+
   unset($form['#default_value']);
   unset($form['#value']);
 
@@ -199,13 +211,17 @@ function cck_select_other_pre_render($fo
 
   $new_form['select_other_list'] = array(
     '#type' => 'select',
+    '#id' => 'edit-field-'.$field_name.'-select-other-list',
     '#title' => t(''),
+    '#description' => t('Select other to enter your own option.'),
     '#options' => $options,
     '#default_value' => $select_def,
+    '#value' => $select_def,
     '#weight' => -10,
   );
   $new_form['select_other_text_input'] = array(
     '#type' => 'textfield',
+    '#id' => 'edit-field-'.$field_name.'-select-other-text-input',
     '#title' => t('Specify other'),
     '#default_value' => ($select_def == 'other') ? check_plain($def) : '',
     '#value' => ($select_def == 'other') ? check_plain($def) : '',
@@ -213,3 +229,22 @@ function cck_select_other_pre_render($fo
 
   return $new_form;
 }
+
+/**
+ * Post-render callback to add javascript functionality
+ * @param $form
+ * @return $form
+ */
+function cck_select_other_post_render($content, $elements) {
+  static $js;
+
+  $field_name = substr($elements['#field_name'], 6);
+
+  if (!$js) {
+    drupal_add_js(array('CCKSelectOther' => array('field' => $field_name)), 'setting');
+    drupal_add_js(drupal_get_path('module', 'cck_select_other').'/cck_select_other.js');
+    $js = TRUE;
+  }
+
+  return $content;
+}
