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.
Comment | File | Size | Author |
---|---|---|---|
#9 | Screenshot - 9_6_2013 , 3_58_09 PM.jpg | 4.84 KB | nathangs |
Comments
Comment #1
dagmarComment #2
yultyyev CreditAttribution: yultyyev commentedDid 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?
Comment #3
yultyyev CreditAttribution: yultyyev commentedI 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.
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.
$view->exposed_raw_input['rooms']=array(
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.
$form_state['input']['rooms']=array(
2 (String, 1 characters ) 2
1 (NULL)
3 (NULL)
);
$form_state['values']['rooms']=array(
2 (String, 1 characters ) 2
1 (Integer) 0
3 (Integer) 0
);
Maybe I should add some extra validation functions to clean up NULL values?
Comment #4
dagmarI 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.
Comment #5
slayne40 CreditAttribution: slayne40 commentedHy.
Same problem with grouped exposed checkbox filter.
I followed the advice of yultyyev :
Thank you
Comment #6
klonos...less vague issue title.
Comment #7
delta CreditAttribution: delta commentedSame 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:
and the function to remove empty values (here 'line_item_label' is the views grouped filter name)
thanks
Comment #8
jlongbottom CreditAttribution: jlongbottom commentedthanks!
#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
Comment #9
nathangs CreditAttribution: nathangs commentedDagmar'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.
Comment #10
daniel.rolls@flightcentre.com.au CreditAttribution: daniel.rolls@flightcentre.com.au commentedIs this issue a duplicate of https://drupal.org/node/1986306#comment-7917249?
I know this is older, but 1986306 defines the issue well.
Comment #10.0
daniel.rolls@flightcentre.com.au CreditAttribution: daniel.rolls@flightcentre.com.au commentedsome mistakes fixed
Comment #11
mstrelan CreditAttribution: mstrelan commentedThis is a duplicate of #1986306: Illegal choice 0 in grouped filters with Allow multiple selections