Hello,

I upgraded to Drupal 6.16 and getting the below warning at all views edit screens.
Can anyone please help?

warning: Invalid argument supplied for foreach() in /home/example/public_html/includes/form.inc on line 1207.

CommentFileSizeAuthor
#14 foreach.txt.gz52.97 KBkenorb
#13 foreach.txt.gz52.97 KBkenorb

Comments

spelcheck’s picture

Ditto, running

Views 6.x-3.x-dev (2010-04-09) w/ views_theme_classes.patch
NodeReferrer 6.x-1.x-dev (2010-Mar-29)

function form_type_checkboxes_value($form, $edit = FALSE) {
  if ($edit === FALSE) {
    $value = array();
    $form += array('#default_value' => array());
    foreach ($form['#default_value'] as $key) { //here is our problem line
      $value[$key] = 1;
    }
    return $value;
  }
  elseif (!isset($edit)) {
    return array();
  }
}

I've got a feeling it's a conflict with NodeReferrer, but let's see what yaz085 says.

dawehner’s picture

On which kind of fields, do you see this behavior.

Its fair from your side, if you provide a way to reproduce problems :)

spelcheck’s picture

After some testing, I'm only seeing it with NodeReferrer module and only when setting the 'Argument' specifically for NodeReferrer. I'm pretty sure it's just a problem with that module but until we hear back from yaz, I guess we're just stalled. Thanks for the quick response!

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Do you have the argument default taxonomy: tid?

dagmar’s picture

Status: Postponed (maintainer needs more info) » Active

I'm pretty sure that this is a duplicate of this #754294: foreach warning produced in views_plugin_argument_default_taxonomy_tid.inc @elizzle, can you try the patch for this issue?

dagmar’s picture

Status: Active » Postponed (maintainer needs more info)

woops... multipost

spelcheck’s picture

I can't test it right this moment, but I can tell you that when I dsm'd $form immediately after
$form += array('#default_value' => array());
$form['#default_value'] was NULL for a checkbox that is taxonomy related. I'm optimistic that's the patch that will do it :D

spelcheck’s picture

That did take care of the error message, but NodeReferrer still isn't saving the status of the checkboxes at the bottom of Argument setup. I'll check in with the author and see what I can find. Thank you for the help, this is definitely a dupe of 754294.

dawehner’s picture

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

#754294: foreach warning produced in views_plugin_argument_default_taxonomy_tid.inc

 but NodeReferrer still isn't saving the status of the checkboxes at the bottom of Argument setup.

Than create an issue on nodereferer. They would have to fix it in their argument handler.

kenorb’s picture

Status: Closed (duplicate) » Active

Not duplicate, because I'm not using taxonomy plugin and I've the same error.

Related issue: #738530: view warning: array_merge() ... Argument #2 is not an array in ... date_api_filter_handler.inc on line 43

kenorb’s picture

URL: /admin/build/views/ajax/config-item/calendar/default/argument/date_argument

warning: Invalid argument supplied for foreach() in includes/form.inc on line 1207.
Backtrace:
form_type_checkboxes_value(string)[form.inc:1014];
._form_builder_handle_input_element(string)[form.inc:883];
..form_builder(string)[form.inc:924];
...form_builder(string)[form.inc:924];
....form_builder(string)[form.inc:924];
.....form_builder(string)[form.inc:924];
......form_builder(string)[form.inc:170];
.......drupal_process_form_new(string)[form.inc:70];
........_drupal_build_form(string)[views.module:1150];
.........drupal_build_form(string)[ajax.inc:128];
..........views_ajax_form_wrapper(string)[admin.inc:1723];
...........views_ui_ajax_form(string)[?:?];
............call_user_func_array(string)[menu.inc:348];
.............menu_execute_active_handler(a:0:{})[index.php:18];
..............index.php
dagmar’s picture

Status: Active » Closed (duplicate)

Not duplicate, because I'm not using taxonomy plugin and I've the same error.

Views load taxonomy plugin as a possible option in a radio box, even if you are not using it.
Please update to the last dev of views 3 and reopen if this bug still persists.

kenorb’s picture

Status: Closed (duplicate) » Active
StatusFileSize
new52.97 KB

More detailed backtrace in attachment.

kenorb’s picture

StatusFileSize
new52.97 KB

SORRY for duplicate!

kenorb’s picture

Status: Closed (duplicate) » Active

Thanks, I'll try.
The difference is that I don't have merge() warning mentioned there.

kenorb’s picture

Status: Active » Closed (duplicate)
kenorb’s picture

kenorb’s picture

Status: Active » Closed (duplicate)

Sorry, I'm confused now:)
Duplicate.

bstrange’s picture

I am not sure if this is helpful or not however, this issue came up when I searched the exact error I am getting. When I attempt to edit a product in Ubercart I get the exact error that the original poster does.

I do not believe the error occurred prior to updating Views, filefield, and CCK yesterday. The versions I am running of each are as follows:

-Views 6.x-2.11 (yes I realize this isn't the version this issue is in queue for but I was unsure if I should start a seperate issue when the error message is identical)
-CCK 6.x-2.7
-FileField 6.x-3.5
-Ubercart 6.x-2.2 (since the problem occurred with an Ubercart product, I will list the Ubercart version as well).

As I felt I may be addressing this issue in the wrong issue queue, I did some more digging and disabled all addons installed yesterday along with the views/cck/filefield updates, and the issue went away. It turns out, the offending module is:

Ubercart Google Base Integration 6.x-1.x-dev

Disabling the module removes the error. I am still hesitant to post this in this issue queue, and if anything, even the line number in the error were different, I would not; but since it is the exact error message, I thought I'd post it up.

If I shouldn't have posted, I apologize, but you never know if the information you provide might provide an "Ah ha!" moment for someone else. :)

Edit to add: Applied Views patch from http://drupal.org/node/754294 and it did not resolve the issue; so it is very possible that my issue is unrelated. I will leave my post up in case anyone else finds this thread searching for the error message resulting from Ubercart Google Base Integration 6.x-1.x-dev and cross post it in their issue queue.

verbosity’s picture

I just had this error, its annoying but more a warning than anything else.

The error happens ( as stated above ) when a checkbox / checkboxes entry has not been set. a simple way to avoid this is to include a line that checks if the array you are going to use is not set and set it as an empty array:
EG:
$default_values=array();
once this is done the error wont be triggered.

If you find this in someones module, let them know, or create a patch, its an easy fix.

brian.sanchez’s picture

I'm not sure if this could help someone, but it helped me,

includes/form.inc

function form_type_checkboxes_value($form, $edit = FALSE) {
if ($edit === FALSE) {
$value = array();
$form += array('#default_value' => array());
if ($form['#default_value']){
foreach ($form['#default_value'] as $key) {
$value[$key] = 1;
}
return $value;
}
}
elseif (!isset($edit)) {
return array();
}
}

the only change is the if ($form['#default_value']){ }

that's it!. the drupal error message is gone.

Best

Brian Sanchez

kenorb’s picture