2

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 ?

enter image description here

2
  • I have the same problem and have been trying to dig thru the Views code that contains this logic - so far no luck
    – Brian
    Commented Jan 28, 2014 at 18:02
  • I think this issue handled your case: drupal.org/project/drupal/issues/2862200
    – yunzen
    Commented May 6, 2020 at 10:25

3 Answers 3

1

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';
    }
  }
1
  • Alternative: $form['field_MY_VALUE_FIELD']['#type'] = 'checkboxes';
    – jaltek
    Commented Aug 5, 2015 at 8:01
0

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.

-2

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.

filters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.