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
Comment #1
karens commentedThere 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.
Comment #2
karens commentedThis turned out to be fixed by #432368: Problems with exposed date filter