Drupal 7.26, Views 7.x-3.7
I have a view with exposed form filters, one of which is a taxonomy terms selection: you select one or many terms to display the nodes having that terms, or you select nothing and you have the complete node list.
The selection widget type is "Autocomplete", which means: when you type some text that doesn't exactly match a term name, you have an error. I can manage to hide the error (views config) but what I want is:
Suppose you have these terms in you vocabulary: "5 stars hotels", "4 stars hotels", "3 stars hotels" and "Private apartments"
When someone types "hotels" and hits submit (without selecting any specific term) I want to show results for any terms that contain the word "hotels" (in this case, the first 3 terms in my vocabulary)
I tried hook_query_alter but the $condition['field'] is a protected ConditionObject so I wasn't able to change it
function MYMODULE_views_query_alter($view, &$query) {
if ( $view->name === "search" ) {
foreach ($query->where as &$condition_group) {
foreach ($condition_group['conditions'] as $conditionKey => &$condition) {
if( is_object( $condition['field'] ) ){
drupal_set_message($condition['field']);
}
}
}
}
}
OUTPUT:
(field_data_field_keywords_value_0.field_keywords_tid = :db_condition_placeholder_2)
Is there a way to act on the query at this level? Or any other approach to do so?