I'm modifying an exposed filter using a hook_form_alter to make it a <select> of type "multiple."

This works great until I select more than one <option> because the original filter in the view is set to "is equal to" (instead of "is one of") so the generated SQL creates a LIKE with the concatenated <option>'s. Despite lots of searching, I cannot find anywhere someone explains how to also change the operator for an exposed filter, in a form_alter programmatically. I was expecting something that would follow these modifications:

$form['field_career_country_value']['#type'] = 'select';
$form['field_career_country_value']['#size'] = NULL;
$form['field_career_country_value']['#multiple'] = TRUE;

Like $form['field_career_country_value']['#operator'], but no such luck. I did find an operator key in $form['#info']['filter-field_career_country_value']['operator'] but the value doesn't make much sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.