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

Comments

meeotch’s picture

Subscribing to this request. I'm getting the same behavior, and won't be able to use this module until a fix goes in.

meeotch’s picture

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;
          }                                                                                                                                                                                             
}
jpollard’s picture

This fix doesn't seem to be working for me. The extra checkbox is still there. Any other thoughts?

andy inman’s picture

Please see this - http://drupal.org/node/242884 - I think it fixes the problem (also new features.)

andy inman’s picture

Status: Active » Fixed

New dev release 4.x fixes this.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

breitner’s picture

Version: 5.x-3.1 » 5.x-4.x-dev

?? no-labeled checkbox appears in release 5.x4.x-dev

andy inman’s picture

Status: Closed (fixed) » Postponed (maintainer needs more info)

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.

breitner’s picture

StatusFileSize
new139.63 KB
new17.42 KB

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]"

breitner’s picture

Version: 5.x-4.x-dev » 5.x-2.x-dev

same problem in version 5.x-2.x-dev.

andy inman’s picture

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.

andy inman’s picture

I think this is fixed. See latest CVS version.

andy inman’s picture

Status: Postponed (maintainer needs more info) » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

tisho-1’s picture

Status: Closed (fixed) » Needs review

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

andy inman’s picture

@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 so
    switch ($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?

tisho-1’s picture

Some php weirdness I guess (I come from C# world, so I am kind of reluctant to understand these :-)):

http://php.net/switch

Note: Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.

Hope this helps!

Tisho

andy inman’s picture

Assigned: Unassigned » andy inman
Status: Needs review » Needs work

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.

andy inman’s picture

Category: support » bug