Drupal - Change default text (-Any-) of select option in Exposed View Filter
If you use the Better Exposed Filters module you can do this using the views interface. Changed exposed form style to 'better exposed filters' and adjust the settings
The Better Exposed Filters module replaces the Views' default single- or multi-select boxes with radio buttons or checkboxes, respectively. Description fields and Select All/None links can be added to exposed filters to make for a better user experience.
I found the solution for this. If anyone is looking for the solution can look into this example.
function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {
//Got the Form Id by using inspect element/Firebug
if($form["#id"] == 'views-exposed-form-tutors-page'){
//field_city_tid is the Filter Identifier Key
$form['field_city_tid']['#options']["All"] = 'Desired Text';
}
}
You can achieve this goal via implementing hook_form_alter
Let e.g.
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'test' && $form_state['view']->current_display == 'page_1') {
// do your alteration stuff
$form['field_city_tid']['#empty_option'] = t('All');// Or whatever you want to do
}
if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'test' && $form_state['view']->current_display == 'page_2') {
// do your alteration stuff
}
}