I am using views exposed filter.

enter image description here

I want to change the text -Any- into something else. How can I do that (without using jquery/javascript) ?


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.

  • Thanks @David Coote. Found an easy solution for now. Will look into this module too to check out the options it provides. – Sandesh Yadav Sep 11 '14 at 12:47
  • Can you please explain how one can do that, David? I don't see this option when I install BEF into Drupal 8. Thanks. – TerranRich Dec 22 '17 at 14:22

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 

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';


  • 2
    It's worth mentioning that the view should be tested: if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'my_view_name' && $form_state['view']->current_display == 'my_view_display_name') { // your code } } – Manu Sep 11 '14 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.