warning: Invalid argument supplied for foreach()

phonydream2 - January 30, 2008 - 17:16
Project:Views Checkboxes
Version:5.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:nschelly
Status:closed
Description

Having installed both 5.x.2.x-dev and 5.x-1.2 versions of this module I am getting:

warning: Invalid argument supplied for foreach() in views_checkboxes.module on line 83.

Line 83 is:

foreach ($form['filter'.$count]['#options'][$option_id]->option as $num => $val) {

Any ideas?

#1

phonydream2 - January 30, 2008 - 18:57

I think I might have fixed it.

Change

line 83:

foreach ($form['filter'.$count]['#options'][$option_id]->option as $num => $val) {
            $newoptions[$num] = $val;
          }

to this:

$newoptions[$option_id] = $option;

I imagine this 'fix' will cause problems later?

Update:

Sorry, I didn't realize there was another bug report about this issue. I could have sworn it wasn't there ten minutes ago :(

#2

nschelly - January 30, 2008 - 20:44
Assigned to:Anonymous» nschelly

That fix isn't really what you want to do. Did the last patch submitted here work for you? http://drupal.org/node/192117
-N

#3

phonydream2 - January 31, 2008 - 00:24

Unfortunately it didn't. It didn't show any error messages, but there was no data shown on my webpage...blank output by your module and everything else normal.

Maybe it's due to the way different versions of Views/CCK deal with checkboxes? Sorry I can't help.

#4

nschelly - January 31, 2008 - 02:39

I'm not sure I'm clear on the problem you're having then. Since you said it had already been reported, I was assuming it was the same as the other issue.

Can you post up a screenshot of the problem and also the exported of the view configuration so I can recreate it?
-N

#5

phonydream2 - January 31, 2008 - 15:11

I'm not having a problem any more and that's because of the 'fix' I described earlier in my thread. My problem was the same as that *originally* described here: http://drupal.org/node/192117

Out of interest (not because I currently seem to need it) I applied this patch (http://drupal.org/files/issues/views_checkboxes-patch.txt) but that didn't work. It didn't give any error messages, but no checkboxes were exposed at all.

I've sent you a PM(email?) with an export of my view.

#6

phonydream2 - January 31, 2008 - 16:42

Ah!! My 'fix' doesn't work with an array of objects...TAXONOMY TERMS! Maybe that's where the problem lies..taxonomy terms are an array of objects whereas CCK select items aren't (just arrays)?? That would explain the foreach error with your module when I try to display a CCK select item and why my 'fix' is working on CCK items and not on taxonomy terms.

A check to see if $form['filter'.$count]['#options'] is an array of objects before looping through it might help.

#7

phonydream2 - January 31, 2008 - 17:02

My idea referred to directly above works for me and all the errors have disappeared. I've attached my module in full, so it's not a patch. It's based on 5.x-1.2.

I don't know how to apply patches yet. :(

Note: you will have to remove the .txt file extension of the included file if this is to work on your Drupal site.

AttachmentSize
views_checkboxes.module.txt 3.48 KB

#8

phonydream2 - January 31, 2008 - 18:08

Update: The 'forced single' option doesn't work. Maybe this is related to the *ALL* filters problem you were referring to in the other issue.

This is the error message I get if I use radiobuttons('force single'):

warning: htmlspecialchars() expects parameter 1 to be string, array given in /hshome/hsphere/local/home/conorole/scoopkorea.com/includes/bootstrap.inc on line 589

#9

nschelly - February 5, 2008 - 21:42

I just posted a new release, 1.3 that I suspect will repair the issue you're reporting. As you suspected, it originated from having select box filters that were not based on taxonomy terms. I was able to get a forced single one to work though, so I'm not entirely sure what problem you were having. I'll keep trying to recreate it. Let me know if you have good luck with the new release, when it posts up.
-N

#10

pinow - February 12, 2008 - 14:52

edit: look at this: http://drupal.org/node/220782

#11

nschelly - February 15, 2008 - 16:25
Status:active» closed

I think this is resolved and pinow's request is being handled in the other issue.
-N

 
 

Drupal is a registered trademark of Dries Buytaert.