warning: Invalid argument supplied for foreach() in w:\home\takerealty.ru\www\sites\all\modules\conditional_fields\conditional_fields.module on line 194.

These warning appear on main page for all users, except admin

Comments

j.slemmer’s picture

See my "solution" on http://drupal.org/node/350411 in post #9 & #10.
The solution needs validating and a patch though.

peterpoe’s picture

Status: Active » Needs review

I can't reproduce the issue. Anyway, while investigating, I found a couple of bugs when handling displaying of conditional fields in conditional_fields_nodeapi, which might have been causing this issue. Please update latest dev to test.

DickSwart’s picture

I get a the same warning but no a different line, this happen when I update or save.

warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\drupal6foxweb\sites\all\modules\conditional_fields\conditional_fields.module on line 738.

jim0203’s picture

I'm getting this too, on various lines: 709, 762, 763. Seemingly happens for all non-admin accounts.

D6
CCK 6.x-2.1
Most recent dev release of Conditional Fields.

ericduran’s picture

I'm using the latest dev.

I'm not sure what's causing everyone else problem but my problem is being cause because I'm using image field.

The problem is this that conditional field tries to prevent an untriggered event from being submitted. In the process it tries to set the value of the untriggered event to the default value. Which works great in almost every field except for an image field because the way it gets the default value.

If you take a look at the code you will see conditional field is looking for 'default_value' the only problem is that the image_field doesn't use 'default_value' it uses 'default_image'.

foreach ($form['#field_info'][$row['field_name']]['widget']['default_value']

Anyways, I'm not that worry about resetting a field if it's untriggered so I just comment out that whole section.

Hope this helps.

servantleader’s picture

Same problem. Same line as #3. (line 738 in 1.0-beta1 and -dev)
foreach ($form['#field_info'][$field_in_group]['widget']['default_value'] as $delta => $value)
The conditional fieldgroup in question contains cck date fields, text fields ,and autocomplete text fields, so I am not sure what is causing it. The problem did not start until I updated to 1.0-beta1. - Code has not changed in most resent dev.

servantleader’s picture

Status: Needs review » Active

I just verified this problem on a clean install - drupal 6.12 , cck 2.2, date 2.2, latest dev of this module.

Trying to save a conditional group containing a date field with the field not triggered produced this error:

warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\drupaltest\sites\all\modules\conditional_fields\conditional_fields.module on line 738.

fred0’s picture

I'm getting the error on line 709 on node creation.
Drupal 6.12
CCK 2.x-dev (2009-May-16)
Date 2.x-dev (2009-May-14)

yrre7’s picture

me, too

ruloweb’s picture

I had the same problem, but in line 711.

I took a look at $form['#field_info'][$field_in_group]['widget']['default_value'] and sometimes it's an array and sometimes is not. So I added a little condition in the "if" above:

before:

        if (!in_array('node_form_build_preview', $form_state['submit_handlers'])) {

after:

        if (!in_array('node_form_build_preview', $form_state['submit_handlers']) && is_array($form['#field_info'][$row['field_name']]['widget']['default_value'])) {

it's not the best solution, but it works for me, I'll take a deeper look later.

Hope it helps, thanks!

Conditional Fields 6.x-1.0-beta1

peterpoe’s picture

Status: Active » Closed (duplicate)