Invalid argument supplied for foreach() on line 89
pinow - February 12, 2008 - 14:37
| Project: | Views Checkboxes |
| Version: | 5.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | nschelly |
| Status: | closed |
Jump to:
Description
The module (1.3) seems to work, but I get this error:
warning: "Invalid argument supplied for foreach() in /modules/views_checkboxes/views_checkboxes.module on line 89."

#1
This only seems to happen when I expose a taxonomy-filter specific(!) for a vocabulary.
"Taxonomy: Terms For Vocab1"
#2
I used the following piece of code from http://drupal.org/node/215935#comment-712436 to fix it:
if (is_object($form['filter'.$count]['#options'][$option_id])) {
foreach ($form['filter'.$count]['#options'][$option_id]->option as $num => $val) {
$newoptions[$num] = $val;
}
} else {
$newoptions[$option_id] = $option;
}
But then I had the "- Please choose -" option visible. So I added the following beneath the line where you disable ***ALL***:
if ($option_id === '') continue;
#3
I can't seem to recreate this - I can't figure out how to make a taxonomy selection show a "- 'Please choose -" listing. Can you send me an export of your view so I can see exactly how you have it configured?
I think you're saying that doing this fixes it by hiding the "- Please choose -" option. Is that correct?
> But then I had the "- Please choose -" option visible. So I added the following beneath the line where you disable ***ALL***:
> if ($option_id === '') continue;
-N
#4
No, I fixed it by using this piece of code:
if (is_object($form['filter'.$count]['#options'][$option_id])) {
foreach ($form['filter'.$count]['#options'][$option_id]->option as $num => $val) {
$newoptions[$num] = $val;
}
} else {
$newoptions[$option_id] = $option;
}
But then the first checkbox-option was "- please choose -".
And I fixed that by adding this:
if ($option_id === '') continue;
#5
I just posted a new release with your bug fix. I don't see how it can harm things, but I couldn't confirm that it works or not because you didn't send what I asked for to recreate the problem.
It's version 3.1 - please read the release notes as a few changes have occurred.
-N