I am using hybrid exposed filters (#731662: Hybrid Exposed Filters), or Grouped filter and have some troubles with it.

I make some grouped (hybrid) filters with checkboxes (e.g. rooms: 1 (=1), 2 (=2), 3+ (>=3), optional, allowed multiple selection, radiobuttons/checkboxes).

When I submit exposed form all works fine, but when none of checkboxes in this filter selected all works only on first page: in url there are none of arguments of this filter (viewspage?myotherargs=somevars), but pager produce url for next pages like this: viewspage?rooms[1]=0&rooms[2]=0&rooms[3]=0&rooms[4]=0&myotherargs=somevars&page=1. So, the second page of view's result is empty with error "An illegal choice has been detected" and checkboxes become selected all.

When I remove wrong part of query rooms[1]=0&rooms[2]=0&rooms[3]=0&rooms[4]=0 from url, the view show normal result page. If I restrict multiple selection, checkboxes become radiobuttons with "Any" value by default, and it works fine too on second and other pages.

#9 Screenshot - 9_6_2013 , 3_58_09 PM.jpg4.84 KBnathangs
Members fund testing for the Drupal project. Drupal Association Learn more


dagmar’s picture

Assigned: Unassigned » dagmar
Issue tags: +Hybrid Filters Follow-ups
yultyyev’s picture

Version: 7.x-3.4 » 7.x-3.5

Did anyone got that trouble? How to produce: add grouped filter with radios (checkboxes) and alowed multiple selection (without default value "All"), add pager. In view's preview now url of pages are generated as filter values filled with 0: field_value[1]=0&field_value[2]=0&field_value[3]=0

Maybe it's my bug?

yultyyev’s picture

I think it is some kind exposed form generation (validation) bug.

I solve the problem by adding following code in view header (block with php), and it's not a good solvation.

foreach($view->exposed_raw_input['rooms'] as $k=>$v){
  if($v==0) {

We have forms with grouped field rooms (1,2,3+, optional, allowed multiple selection)

Ok, what I found:

Troubles starts from $view->exposed_raw_input.
2 (String, 1 characters ) 2
1 (Integer) 0
3 (Integer) 0

$view->exposed_raw_input gets it's values in function views_exposed_form_submit(&$form, &$form_state) (views.module), from $form_state['values'], and it contains data recieved in function views_exposed_form_validate(&$form, &$form_state), and there are values from form.inc validation functions.

2 (String, 1 characters ) 2
1 (NULL)
3 (NULL)

2 (String, 1 characters ) 2
1 (Integer) 0
3 (Integer) 0

Maybe I should add some extra validation functions to clean up NULL values?

dagmar’s picture

I don't have time to create a patch right now, but maybe the problem is that checkboxes doesn't work well with exposed filters, this was the reason due views don't provide checkboxes for multiple options and the module Better Exposed Filters exists.

Maybe changing the widget from 'checkboxes' into 'select' with the #multiple => TRUE option enabled fix the issue, and with Better Exposed Filters theme the select to look like checkboxes again.

slayne40’s picture

Version: 7.x-3.5 » 7.x-3.6
Assigned: dagmar » Unassigned

Same problem with grouped exposed checkbox filter.
I followed the advice of yultyyev :

  • I altered the exposed form, and add a validate function.
  • In this function I deleted the empty values.

Thank you

klonos’s picture

Title: Problem with hybrid exposed filters » "An illegal choice has been detected" error when using hybrid exposed filters.
Version: 7.x-3.6 » 7.x-3.x-dev

...less vague issue title.

delta’s picture

Same issue, applying what #3 says works for me.

here is the code i use :

In a hook form alter, i add a validate function on the exposed views form:

$form['#validate'][] = 'commerce_backoffice_orders_list_form_validate_hybrid_filters';

and the function to remove empty values (here 'line_item_label' is the views grouped filter name)

function commerce_backoffice_orders_list_form_validate_hybrid_filters(&$form, &$form_state) {
  $values =& $form_state['values'];
  if (isset($values['line_item_label']) && !empty($values['line_item_label'])) {
    foreach ($values['line_item_label'] as $key => $value) {
      if (empty($value)) {


jlongbottom’s picture


#3 and #7 both worked, but I didn't want to install Views PHP just for this so I opted for #7 in template.php

nathangs’s picture

Dagmar's suggestion worked for me:
"Maybe changing the widget from 'checkboxes' into 'select' with the #multiple => TRUE option enabled fix the issue, and with Better Exposed Filters theme the select to look like checkboxes again."

My setup was, using a grouped exposed filter and trying to format it as a list of checkboxes. I had better exposed filters active and selected the "Checkboxes/Radio buttons" option as usual for the exposed filter, but it displayed as radio buttons. Was also having trouble changing the exposed filter options (some weren't saving correctly). It started working normally once I change the better exposed filters settings back to default select list.

rollsd’s picture

Is this issue a duplicate of https://drupal.org/node/1986306#comment-7917249?

I know this is older, but 1986306 defines the issue well.

rollsd’s picture

Issue summary: View changes

some mistakes fixed

mstrelan’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)