How to set the first option as the selected in the SELECT form via hook_form_alter I have created a Views with an exposed filter and I tried to use hook_form_alter to convert it to a select list. Now, I need to set the default value as the first option whatever output in the select list. I DONT'T need to have '-Any-' as the default value which usually do. I wonder how can I achieve this. The page keep showing the below message when first visit the page not until one of the option is selected and applied.


  An illegal choice has been detected. Please contact the site
  administrator.


Here the code in my template.php. Hope you can help me out. Thanks!

if($form_id == 'views_exposed_form' &amp;&amp; $form['#id']=='views-exposed-form-news-page') { 

     //Query
     $query = db_select('node', 'n');
     $query-&gt;fields('n', array('title'));
     $query-&gt;condition('n.type', 'news');
     $query-&gt;orderby('n.title', 'ASC');
     $result = $query-&gt;execute();

     // Get Select options 
     $options = array();  

     foreach( $result as $node ){
       $options[$node-&gt;title] = $node-&gt;title;
     }


    // Alter the form
        $form['title_1'] = array(
         '#type' =&gt; 'select',
         //'#default_value' =&gt; ??
         '#options' =&gt; $options,
         '#title' =&gt; t('Filter By'), 
    ); 
 }
You need to add the following code to your implementation of hook_form_alter():

if (empty($form_state['input']['title_1'])) {    
  // set the first element as default value
  $form_state['input']['title_1'] = reset($options);
}