Hook_Form_Alter Edit Existing Field Type I am using hook_form_alter in template.php to add datepicker to a field on an exposed view filter.

function MYTHEME_form_alter(&amp;$form, &amp;$form_state, $form_id) {

  if($form_id == "views_exposed_form"){
    $form['data_2_op'] = array(
            '#type' =&gt; 'date_popup',
            '#date_format' =&gt; 'Y-m-d'
        );
    }
}


But all it is doing is adding another field into the form, rather than editing the field I have declared. Is there a way I can just add #type > 'date_popup' to an existing field?

EDIT:

Results after using...

drupal_set_message($form_id);  // print form ID to messages
  drupal_set_message(print_r($form, TRUE));  // print array to messages

views_exposed_form
Array ( 
  [#info] =&gt; Array ( 
    [filter-combine] =&gt; Array ( 
      [operator] =&gt; combine_op 
      [value] =&gt; combine 
      [label] =&gt; Search Event ID 
      [description] =&gt; 
    ) 
[filter-data_2] =&gt; Array ( 
  [operator] =&gt; data_2_op 
  [value] =&gt; data_2 
  [label] =&gt; Choose Date [description] =&gt; 
  )
[filter-data] =&gt; Array ( 
  [value] =&gt; data 
  [label] =&gt; Data field 
  [description] =&gt; ) 
  [filter-data_1] =&gt; Array ( 
    [value] =&gt; data_1 
    [label] =&gt; Data field 
    [description] =&gt; 
    ) 
  ) 
[combine] =&gt; Array ( 
  [#type] =&gt; textfield 
  [#size] =&gt; 30 
  [#default_value] =&gt; ) 
[data_2] =&gt; Array (
  [#type] =&gt; textfield 
  [#size] =&gt; 30 
  [#default_value] =&gt; )
hook_form_alter work only with module implementation. So you have to use it in any module not in template.php

Use the above statement in module like 

function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {

  if($form_id == "views_exposed_form"){
    $form['data_2'] = array(
            '#type' =&gt; 'date_popup',
            '#date_format' =&gt; 'Y-m-d'
        );
    }
}