I have a grouped filter in a view with lets say 3 items. For the Widget i choose Radios and Allow multiple selections. For 3 Items everything works fine and i have some checkboxes. Wenn they are more then 3 items instead of checkboxes there is a select list! But i want to have checkboxes. Even Better Exposed Filters only shows select as an option for that filter. Whats wrong ?
3 Answers
I came up with writing a simple hook:
function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state, $form_id)
{
if ($form['#id'] == 'MYFORMID') {
$form['field_MY_VALUE_FIELD']['#theme'] = 'select_as_checkboxes';
}
}
-
Alternative: $form['field_MY_VALUE_FIELD']['#type'] = 'checkboxes';– jaltekCommented Aug 5, 2015 at 8:01
The code that handle this conditional change between a multiselect and individual checkboxes is in views_handler_filter.inc
in the function group_form
:
if (count($groups) < 5) {
$form[$value]['#type'] = 'checkboxes';
}
else {
$form[$value]['#type'] = 'select';
$form[$value]['#size'] = 5;
$form[$value]['#multiple'] = TRUE;
}
Since it cannot be manipulated with any views options, the best way to handle this is to hook alter the form and just force it to always be checkboxes (or select if that's what you want).
This is suggested by the user "oll", but I don't see the need to change how the element is themed. You just need to change the type.
I have the same problem, but I can get up to four items. My workaround was to just add more grouped filters, making sure to use the OR grouping.