Add new comment

I have followed the tutorial and its really helpful. However i am receiving following error when i change the dropdown.
The form has become outdated. Copy any unsaved work in the form below and then reload this page.
Please help in to solve this

<?php
function alterfilter_form_views_exposed_form_alter(&$form, &$form_state){ 



  if (
$form['#id'] == 'views-exposed-form-bike-search-page') {
   
   
$selectedTerm = $form_state['input']['term_node_tid_depth'];
   
   
$form['nid']['#type'] = 'select';
$form['nid']['#size'] = null;
$form['nid']['#default_value'] = 0;
$form['nid']['#options'] = _get_associative_array_from_view(
     
'bike_search', // view id
     
'block_1', // view display id
     
'nid', // key field id
     
'node_title', // value field id
     
$selectedTerm // term id of the selected shape
   
);
$form['nid']['#validated'] = true;   
$form['term_node_tid_depth']['#ajax'] = array(
 
'callback' => '_update_colors_callback',
 
'wrapper' => 'colors_wrapper',
);
$form['nid']['#prefix'] = '<div id="colors_wrapper">';
$form['nid']['#suffix'] = '</div>';
  }
}
?>

<?php
function _get_associative_array_from_view($viewID, $viewDisplayID, $keyFieldID, $valueFieldID, $contextualFilter){
 
 
$associativeArray = array();
 
$associativeArray['All'] = t('- Any -');
 
$viewResults = views_get_view_result($viewID, $viewDisplayID, $contextualFilter);
  foreach(
$viewResults as $viewRow) {
   
$associativeArray[$viewRow->$keyFieldID] = $viewRow->$valueFieldID;
  }
  return
$associativeArray;

}

?>


<?php
function _update_colors_callback($form, $form_state) {
  return
$form['nid'];
}
?>