I want to alter an exposed filter of a view to add a new field to the existing filter. I tried the same with hook_views_pre_view() and the new filter field added successfully. But after typing something to that autocomplete field, that field disappears. Means on the first page load, field displaying correctly but when AJAX starts it disappears. Also I tried with other hook functions like hook_views_pre_build and hook_views_pre_execute(). Can any one help me on this? Thanks.
function modulename_views_pre_view(&$view) {
if ($view->name == 'my_view_name') {
$view_filters = $view->display_handler->get_option('filters');
//Add new field
$view_filters['new_field'] = array(
'id' => 'new_field',
..
..
);
$view->display_handler->override_option('filters', $view_filters);
}
}