<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Form alter to force exposed views filters to fllow filter options'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Sun, 26 May 2013 00:54:59 GMT</pubDate>
<item>
<title>dduane said on 7/15/09</title>
<link>http://snipplr.com/view/2674/form-alter-to-force-exposed-views-filters-to-fllow-filter-options/</link>
<description><![CDATA[ This is the way I ended up solving this problem:

I put this snippet into my hook_form_alter()  function

	  $form['field_field_name_value'] = array(
	     '#type' => 'select',
            '#default_value' => 'All',
            '#options' => field_name_option_values(),
	  );



// Then here is the function that returns the options that came out of the drupal table

function field_name_option_values() {
        // content_fields function retrieves the possible values out of the drupal database table
	$field = content_fields('field_field_name',NULL);
	 $options = explode(chr(10), $field['allowed_values']); 
	  
	 $new_options['All']='';
     // this cleans it up so that the field names are indexes to the array.  In other cases you may want to put number codes here.  
	 foreach ($options AS $option)
	 {  $new_options[trim($option)]=trim($option); }
	 
	 return $new_options;
}

/////////////////Here is another possible example of this function if you have key/ value pairs specified in your CCK type delinted with pipes.


function   field_name_2_option_values() {
	
	$field = content_fields('field_field_name',NULL);
	 $options = explode(chr(10), $field['allowed_values']); 
	 
	 $new_options['All']='';
	 
	 foreach ($options AS $option) {
	 	$op = explode('|',$option);
		$key = trim($op[0]);
		if($key != '') 
  		  $new_options[$key] = $op[1];
	 }
	 
	 return $new_options;
	
} ]]></description>
<pubDate>Wed, 15 Jul 2009 16:40:58 GMT</pubDate>
<guid>http://snipplr.com/view/2674/form-alter-to-force-exposed-views-filters-to-fllow-filter-options/</guid>
</item>
<item>
<title>thededalus said on 10/7/07</title>
<link>http://snipplr.com/view/2674/form-alter-to-force-exposed-views-filters-to-fllow-filter-options/</link>
<description><![CDATA[ <p>where does this snippet go?</p>
 ]]></description>
<pubDate>Sun, 07 Oct 2007 08:11:01 GMT</pubDate>
<guid>http://snipplr.com/view/2674/form-alter-to-force-exposed-views-filters-to-fllow-filter-options/</guid>
</item>
</channel>
</rss>