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) ?

4 Answers 4


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
    Commented Sep 11, 2014 at 12:44

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. Commented Sep 11, 2014 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
    Commented Dec 22, 2017 at 14:22
  • For Drupal 10, in the Better Exposed Filter settings, under "Exposed Filter Settings" and under the specified filter (Exposed filter "<filter name here>") there is an "Advanced Filter Options" expandable details element with a field labeled "Rewrite the text displayed". In that field put the text "- Any -|- Select-" on a single line and it will changed the default "- Any -" to "- Select".
    – ZroonStack
    Commented Mar 13 at 21:11

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 

Concrete example of an exposed Boolean filter for a view on a custom entity. Note that I had to add _value to field names.

  • Custom module name: rsc
  • View machine name: transactions
  • Page machine name: purchase
  • Field name: field_order_shipped

Actual code:

function rsc_form_views_exposed_form_alter(&$form, &$form_state)
  if ($form['#id'] == 'views-exposed-form-transactions-purchase') {
    $form['field_order_shipped_value']['#options']['All'] = 'Any';
    $form['field_order_shipped_value']['#options']['1'] = 'Yes';
    $form['field_order_shipped_value']['#options']['0'] = 'No';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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