? .svn
? select_or_other-946532.patch
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.3
diff -u -p -r1.1.2.1.2.10.2.3 select_or_other.module
--- select_or_other.module	14 Dec 2010 04:06:17 -0000	1.1.2.1.2.10.2.3
+++ select_or_other.module	15 Feb 2011 19:03:36 -0000
@@ -578,10 +578,35 @@ function theme_select_or_other_none($fie
  * Integrate with apachesolr.module.
  */
 function select_or_other_apachesolr_cck_fields_alter(&$mappings) {
-  $mappings['text']['select_or_other_buttons'] = array(
+  $mappings['text']['select_or_other_buttons'] = $mappings['text']['select_or_other'] = $mappings['text']['select_or_other_sort'] = array(
     'display_callback' => 'apachesolr_cck_text_field_callback',
     'indexing_callback' => 'apachesolr_cck_text_indexing_callback',
     'index_type' => 'string',
     'facets' => TRUE,
   );
-}
\ No newline at end of file
+}
+
+/**
+ * Implementation of hook_content_allowed_values_alter().
+ *
+ * Integrate with CCK for properly displaying key|value options.
+ */
+function select_or_other_content_allowed_values_alter( &$allowed_values, $field ) {
+  // Test the operation to avoid validation error with text field valudation on saving
+  if ( $field['widget']['module'] == 'select_or_other' && $_POST['op'] != t('Save') ) { 
+    $list = explode("\n", $field['widget']['available_options']);
+    $list = array_map('trim', $list);
+    $list = array_filter($list, 'strlen');
+    foreach ( $list as $opt ) {
+      // Sanitize the user input with a permissive filter.
+      $opt = content_filter_xss($opt);
+      if ( strpos($opt, '|') !== FALSE ) {
+        list($key, $value) = explode('|', $opt);
+        $allowed_values[$key] = (isset($value) && $value !=='') ? $value : $key;
+      }
+      else {
+        $allowed_values[$opt] = $opt;
+      }
+    }
+  }
+}
