Changing label of views exposed date filter select list Trying to change the label of a views exposed date filter based on Year granularity which is a select list. I have given date range to the filter thus it does not generate the "#options" array.

It creates a dropdown with year values and a "-Year" to display all values.

I want to rename this "-Year" label. Could not find any options within the view to change this label. So is there any hook or alter that can be used here ? 



Yes i am using Better exposed filter and trying to use Date filter based on Content Post Date. After applying BEF i get a select list to the exposed date filter. I need to change the "-Year" label inside this dropdown. tried using hook_form_alter but not able to search this label and change it.



Attached a screenshot of the settings page for the Date filter. And under BEF settings I selected the Default select list option. Could not find any way to rename the "-Year" label.
Looks like this is something we have already on drupal issue-queue as https://www.drupal.org/node/2296607.

I was expecting the options to be alterable by any hook, unfortunately could not find any.

I explored the code in date module, and found the elements are processed by a function as date_parts_element, under which it appending '-' before the label.

Now, while the following will fix your issue but I would nor recommend it to you until it is approved by community. The hack is

In your date_api_elements.inc file(date/date_api) inside function date_parts_element add this line drupal_alter('date_process_element', $sub_element); in the bottom just before return $element; so it looks as 

    ..... 
    if ($element['#date_label_position'] == 'within') {
      $sub_element['ampm']['#options'] = array('' =&gt; '-' . $label) + $sub_element['ampm']['#options'];
    }
  }
  drupal_alter('date_process_element', $sub_element);
  return $sub_element;
}


This will allow any custom module to alter the elements of date filter. Now in your custom module let's say named as my_module implement the hook we have added as following

/**
  * Implements hook_date_process_element_alter.
 */
function my_module_views_date_process_element_alter(&amp;$element) {
  foreach($element['year']['#options'] as $key=&gt;$value) {
    if($value == '-Year') {
        $element['year']['#options'][$key] = 'Year';// Or whatever you like to give.
    }
  }
}


I will be adding the same suggestion on drupal issue page.

Update

Indeed no patch required, date module provides the hooks out of the box, got to know from update mentioned issue feeds, didn't try the cpde myself but looks promising

function MYMODULE_date_select_process_alter(&amp;$element, &amp;$form_state, $context) {
  // Tweak the -Year filter to remove the -
  if (empty($element['year'])) return;
  foreach ($element['year']['#options'] as $key =&gt; $value) {
    if ($value == '-Year') {
      $element['year']['#options'][$key] = 'Select Year';
      break;
    }
  }
}