--- views_filters_selective/views_filters_selective.module	2010-05-24 17:11:51.000000000 +0200
+++ views_filters_selective/views_filters_selectiveNew.module	2010-08-02 19:23:42.000000000 +0200
@@ -17,10 +17,8 @@ function views_filters_selective_form_vi
   // Go through each filter checking for a 'selective' setting
   foreach ($form_state['view']->filter as $field => $filter) {
     if ($filter->options['exposed']) {
-
       // Form element is designated by the element ID which is user-configurable
       $field_id = $form['#info']["filter-$field"]['value'];
-      if (!isset($form[$field_id]['#options'])) continue;
 
       // If using selective filters, filter the value_options based on view results
       if ($filter->options['expose']['vfs_selective']) {
@@ -31,6 +29,7 @@ function views_filters_selective_form_vi
           static $guard = FALSE; // We don't want to be back here when we execute the cloned view
           if (!$guard) {
             $guard = TRUE;
+						
             $view = $form_state['view']->clone_view();
 
             // Add our selective field helper.
@@ -67,30 +66,31 @@ function views_filters_selective_form_vi
           }
         }
         if (!empty($results[$resultset])) {
+					if ($form[$field_id]['#type'] === 'textfield') {
+						$form[$field_id] = array(
+							'#type' => 'select',
+							'#options' => array(),
+						);
+						
+						$filter->exposed_translate($form[$field_id], 'value');
+						
+						$form[$field_id]['#options'][''] = $form[$field_id]['#options']['All'];
+						unset($form[$field_id]['#options']['All']);
+					}
+					
           foreach ($query_fields[$resultset] as $query_field) {
             if (/*$query_field['table'] == $filter->table && */$query_field['field'] == $filter->real_field) {
               $field_alias = $query_field['alias'];
               break;
             }
           }
-          if (!isset($field_alias)) {
-            // Do nothing.
-          }
-          else {
-            $options = array();
-            $null_option_exists = FALSE;
+          
+          if (isset($field_alias)) {
+            $options = &$form[$field_id]['#options'];
             foreach ($results[$resultset] as $row) {
-              if (isset($row->$field_alias)) {
-                $options[$row->$field_alias] = TRUE;
-              }
-              else if (is_null($row->$field_alias)) {
-                $null_option_exists = TRUE;
-              }
+							if (isset($row->$field_alias))
+								$options[$row->$field_alias] = (isset($options[$row->$field_alias])) ? $options[$row->$field_alias] : $row->$field_alias;
             }
-            if ($filter->options['expose']['optional']) {
-              $options['All'] = TRUE;
-            }
-            $form[$field_id]['#options'] = array_intersect_key($form[$field_id]['#options'], $options);
           }
         }
       }
@@ -105,34 +105,39 @@ function views_filters_selective_form_vi
   if (empty($form['options']['expose'])) return;
 
   // Is this a field we can override?
-  $overrideable = array('select', 'checkboxes', 'radios');
-  if (!in_array($form['options']['value']['#type'], $overrideable)) {
+  $s_overrideable = in_array($form['options']['value']['#type'], array('select', 'checkboxes', 'radios', 'textfield'));
+  $a_overrideable = in_array($form['options']['value']['#type'], array('select', 'checkboxes', 'radios'));
+  if (!$s_overrideable && !$a_overrideable) {
     return;
   }
 
   // Build form elements for the right side of the exposed filter form
   $right = array();
-
-  $right['vfs_selective'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Limit list to result set'),
-    '#default_value' => @$form_state['handler']->options['expose']['vfs_selective'],
-    '#description' => t(
-      'If checked, the only items presented to the user will be the ones present in the result set.'
-    ),
-  );
-
-  $right['vfs_active'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Further limit list to active filters'),
-    '#default_value' => @$form_state['handler']->options['expose']['vfs_active'],
-    '#description' => t(
-      'If checked, the items presented to the user will be further restricted according to
-       the values of all active exposed filters (i.e., those with selected values). 
-       This option will only kick in if the "!limit" above is checked.', 
-       array('!limit' => t('Limit list to result set'))
-    ),
-  );
+	
+	if ($s_overrideable) {
+		$right['vfs_selective'] = array(
+			'#type' => 'checkbox',
+			'#title' => t('Limit list to result set'),
+			'#default_value' => @$form_state['handler']->options['expose']['vfs_selective'],
+			'#description' => t(
+				'If checked, the only items presented to the user will be the ones present in the result set.'
+			),
+		);
+	}
+	
+	if ($a_overrideable) {
+		$right['vfs_active'] = array(
+			'#type' => 'checkbox',
+			'#title' => t('Further limit list to active filters'),
+			'#default_value' => @$form_state['handler']->options['expose']['vfs_active'],
+			'#description' => t(
+				'If checked, the items presented to the user will be further restricted according to
+				 the values of all active exposed filters (i.e., those with selected values). 
+				 This option will only kick in if the "!limit" above is checked.', 
+				 array('!limit' => t('Limit list to result set'))
+			),
+		);
+	}
 
   $expose = $form['options']['expose'];
   $first_chunk = array_splice($expose, 0, array_search('end_checkboxes', array_keys($expose)));
