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

AttachmentSize
views_checkboxes.png6.65 KB

#1

meeotch - March 8, 2008 - 02:19

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

meeotch - March 10, 2008 - 01:24

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

jpollard - March 17, 2008 - 13:52

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

#4

netgenius - April 5, 2008 - 02:52

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

#5

netgenius - April 5, 2008 - 19:47
Status:active» fixed

New dev release 4.x fixes this.

#6

Anonymous (not verified) - April 19, 2008 - 19:51
Status:fixed» closed

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

#7

breitner - April 29, 2008 - 11:38
Version:5.x-3.1» 5.x-4.x-dev

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

#8

netgenius - April 29, 2008 - 11:49
Status:closed» 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.

#9

breitner - April 29, 2008 - 12:24

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

AttachmentSize
title_checkboxes.jpg 17.42 KB
false_taxonomy.jpg 139.63 KB

#10

breitner - April 30, 2008 - 17:14
Version:5.x-4.x-dev» 5.x-2.x-dev

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

#11

netgenius - April 30, 2008 - 17:39

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

netgenius - June 9, 2008 - 22:20

I think this is fixed. See latest CVS version.

#13

netgenius - June 9, 2008 - 22:28
Status:postponed (maintainer needs more info)» fixed

#14

Anonymous (not verified) - June 23, 2008 - 22:32
Status:fixed» closed

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

#15

tisho - September 4, 2008 - 11:39
Status:closed» 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

#16

netgenius - September 4, 2008 - 16:34

@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?

#17

tisho - September 4, 2008 - 21:23

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

#18

netgenius - September 5, 2008 - 07:06
Assigned to:Anonymous» netgenius
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.

#19

netgenius - September 5, 2008 - 07:08
Category:support request» bug report
 
 

Drupal is a registered trademark of Dries Buytaert.