In a view, i have an exposed date filter.

If the value is empty, date filter should be disabled.
It's not the case, when the value is empty, 'query' function add an SQL condition.

I find this solution :
In date_api_filter_handler.inc
Add this code

function date_filter($prefix, $query_field, $operator) {
    $field = $query_field['field'];
    // Handle the simple operators first.
    if ($operator == 'empty') {
      $this->add_date_field($field);
      return $field['fullname'] .' IS NULL';
    }
    elseif ($operator == 'not empty') {
      $this->add_date_field($field);
      return $field['fullname'] .' IS NOT NULL';
    }

    // If there is no value, do no filtering.
    $value_parts = (array) $this->value[$prefix];
    
    //TO ADD : test if array is empty
	if (empty($value_parts)) {
		return '';
	}
    //END TO ADD

Comments

karens’s picture

Status: Needs work » Postponed (maintainer needs more info)

There is no query added if the filter is empty. So I don't know where you're seeing that. the date_filter function is not even called if the filter is empty.

karens’s picture

Status: Postponed (maintainer needs more info) » Fixed

This turned out to be fixed by #432368: Problems with exposed date filter

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.