when filter is optional, a no-labeled checkbox appears
leanazulyoro - February 23, 2008 - 18:56
| Project: | Views Checkboxes |
| Version: | 5.x-2.x-dev |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | netgenius |
| Status: | needs work |
Description
here's my problem. when i have a cck text filter optional and allow multiple selections, a no-labeled checkbox appears on top of the rest. I guess this checkbox stands for the "All" option. the thing is that it should not appear, just like in the case of a taxonomy filter. i mean, if i use a taxonomy filter, also multiple, also optional, that checkbox doesn't appear, this is how it is supossed to work for all the cases right?
attached are screenshots of both, the taxonomy (working correctly) and the cck text (the other way about) before and after views_checkboxes. Thanks in advance
| Attachment | Size |
|---|---|
| views_checkboxes.png | 6.65 KB |

#1
Subscribing to this request. I'm getting the same behavior, and won't be able to use this module until a fix goes in.
#2
Update - I don't have time to figure out how to make this a patch, but here's code that fixes the problem:
Remove the second-to-last "if" clause in views_checkbox.module:
if ($recreate_options AND !is_object($form['filter'.$count]['#options'][0])) {# We won't recreate the options if they are already of the simple array type.
# Taxonomy options will be an array of objects handled below.
$recreate_options = FALSE;
}
And replace the last "if" clause with this:
foreach ($form['filter'.$count]['#options'] as $option_id => $option) {
// I'm disabling the **ALL** option entirely, if it exists.
if ($option_id === '**ALL**') continue;
// I'm disabling the "- Please choose -" option some have reported.
if ($option_id === '') continue;
if (is_object($option)) {
foreach ($form['filter'.$count]['#options'][$option_id]->option as $num => $val) {
$newoptions[$num] = $val;
}
} else {
$newoptions[$option_id] = $option;
}
}
#3
This fix doesn't seem to be working for me. The extra checkbox is still there. Any other thoughts?
#4
Please see this - http://drupal.org/node/242884 - I think it fixes the problem (also new features.)
#5
New dev release 4.x fixes this.
#6
Automatically closed -- issue fixed for two weeks with no activity.
#7
?? no-labeled checkbox appears in release 5.x4.x-dev
#8
Are you absolutely sure you're using the current release? (no old version hanging around somewhere?) I verified the original problem and definitely fixed it, checked on my test and live sites. I'm not syaing it's impossible that there's no outstanding problem, but I can't reproduce it. If you're willing to do more testing, let me know, and we can put a debug version together to find out whats going on.
#9
I use the last dev-version from 2008-Apr-08.
The title of all checkboxes are "Object".
I think there is an error at this point: name="filter0[1]"
#10
same problem in version 5.x-2.x-dev.
#11
Ok, I won't get a chance to look at this until next week, but then I'll write some debug code in to find out what's causing the problem. In the meantime, could you give me a list of all modules you have enabled - it could be some inter-module compatibility issue. Also, possibly it's language dependent - if you haven't already done so, could you check that it also happens with the site switched to English? Thanks.
#12
I think this is fixed. See latest CVS version.
#13
#14
Automatically closed -- issue fixed for two weeks with no activity.
#15
Hi there,
I found a bug which is probably introduced in the fix for removing the **ALL** option. The problem is that this option is missing in select list as well as checkbox and radio buttons but it should be present in select lists.
I am relatively new to drupal and patching but here is the fix that worked for me:
old code, line 140:
// Remove the "**ALL**" option if it exists:
if (isset($these_options['**ALL**'])) unset($these_options['**ALL**']);
new code, line 140:
// Remove the "**ALL**" option if it exists but not in select lists:
if (isset($these_options['**ALL**']) && $this_type != 'select') unset($these_options['**ALL**']);
Hope this helps!
Tisho
#16
@Tisho, thanks for the patch. Weird though - it shouldn't get as far as line 140 unless converting the select to radio/checkbox, and looking at the code I can't see how that's happening. What I mean is, I can't see how your patch can achieve anything, since the switch block above makes it impossible(?!) to arrive at line 140 unless $this_type=='checkboxes' || $this_type=='radios'. In all 'continue' in other cases so will loop back to the top:
// Check to see if we will have anything more to do and set up new types if soswitch ($exposed['single']) {
case 0: // Not single: use checkboxes
if (!$checkbox_enable) continue; // Not enabled, skip
$this_type = 'checkboxes'; // Set new type
break;
case 1: // Single: use radios
if (!$radio_enable) continue; // Not enabled, skip
$this_type = 'radios'; // Set new type
break;
default:
continue; // Neither (!?) so skip it anyway
}
... so I must be missing something?
#17
Some php weirdness I guess (I come from C# world, so I am kind of reluctant to understand these :-)):
http://php.net/switch
Hope this helps!
Tisho
#18
Aargh! Right, well, that would explain it wouldn't it!?
Thanks for that bit of research. Looks like I need to go back to PHP school! Likewise, I cut my teeth on C (um, and assembler...) So, those continue statements in the switch block all need to be 'continue 2'. Or maybe just replace the switch with an if structure.
I'll fix it in the dev version asap, and try to get a new release out as its obviously a bit broken.
Thanks again.
#19