I have the CCK version 6.x-3.x-dev with version 6.x-3.1 installed, and mostly the module works fine.

However, if I have an imagefield with the "Unlimited" option enabled there is a problem.

When editing the node and adding the first image (i.e. the first time the "Add another item" button is clicked), I get the following errors: -

* warning: Invalid argument supplied for foreach() in /sites/all/modules/cck/includes/content.node_form.inc on line 456.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /sites/all/modules/cck/includes/content.node_form.inc on line 464.
* warning: Wrong parameter count for max() in /sites/all/modules/cck/includes/content.node_form.inc on line 464.

At first, I thought this was a CCK issue (it could be) but testing with other CCK fields (e.g. text, number etc.) seems to be OK.

The rest of the process works fine - I can upload an image and it is displayed. Clicking "Add another item" again also works fine once the first field is there.

Thanks,

Dubs

CommentFileSizeAuthor
#1 fix.png10.43 KBbeetbe.com
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

beetbe.com’s picture

FileSize
10.43 KB

I have the same problem with my website. The problem comes from Ubercart Image upload field and CCK

* warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Group\Apache2\htdocs\fakoon2\modules\cck\includes\content.node_form.inc on line 456.
* warning: array_keys() [function.array-keys]: The first argument should be an array in C:\Program Files\Apache Group\Apache2\htdocs\fakoon2\modules\cck\includes\content.node_form.inc on line 464.
* warning: Wrong parameter count for max() in C:\Program Files\Apache Group\Apache2\htdocs\fakoon2\modules\cck\includes\content.node_form.inc on line 464.

How to solve this ?

benthomas1975’s picture

I too am getting this same error message, searched through Ubercart and Drupal and this is the only mention of it, I assume it is a new problem?? HELP!

Roman V.D.’s picture

The same problem! HELP!

edemus’s picture

Roman V.D.’s picture

We need any developers comments! Help please!

beetbe.com’s picture

No one here! A lot of issues still has no question. I am really tired with a lot of potential dangers are coming with other drupal's modules

Roman V.D.’s picture

UP!

lowVocal’s picture

SAME:

CCK 6.x-3.x-dev (2009-Aug-29)
ImageField 6.x-3.1

Initially no field is present -- just submit button.

Then when submitted (to see what it forces to happen) I get this:

* warning: Invalid argument supplied for foreach() in /var/www/dev6.site.org/sites/all/modules/contrib/cck/includes/content.node_form.inc on line 456.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/dev6.site.org/sites/all/modules/contrib/cck/includes/content.node_form.inc on line 464.
* warning: Wrong parameter count for max() in /var/www/dev6.site.org/sites/all/modules/contrib/cck/includes/content.node_form.inc on line 464.

Thanks.

techgu’s picture

I have the same issue.

When I try to create a product the button below Image says "Add another item" when you click the button it brings up this error message:

* warning: Invalid argument supplied for foreach() in /modules/cck/includes/content.node_form.inc on line 456.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /modules/cck/includes/content.node_form.inc on line 464.
* warning: Wrong parameter count for max() in //modules/cck/includes/content.node_form.inc on line 464.

However if you go to edit an item you can add a picture no problem.

lowVocal’s picture

Not conclusive, and not a fix.

I altered the widget type from "image" to image FUpload after installing the FUpload module (for a different unrelated purpose.)

The field shows now and works — ...?

There is a bug, or perhaps an image upload/imagefield conflict — I'm guessing...

ThePiano.SG’s picture

subscribe

..............................................’s picture

+

Patsjoelie’s picture

Same problem, no solution.
Subscribing

dungiis’s picture

lot of problems are the same

twooten’s picture

I have the same issue. I do not have Ubercart or FUpload installed so it's not coming from either of those modules.
This is a Drupal 6.14 install fully updated.

I get the following.

* warning: Invalid argument supplied for foreach() in /home/wwd/public_html/sites/all/modules/cck/includes/content.node_form.inc on line 456.
* warning: array_keys() [function.array-keys]: The first argument should be an array in /home/wwd/public_html/sites/all/modules/cck/includes/content.node_form.inc on line 464.
* warning: Wrong parameter count for max() in /home/wwd/public_html/sites/all/modules/cck/includes/content.node_form.inc on line 464.

Tim

kruser’s picture

subscribing

robino’s picture

Hi, I suddenly had the same problem and then figured it was because I had upgraded my cck to version to 6.x-2.x-dev. I just went back to 6.x-2.5 and there is no bug.

amcc’s picture

I have the same problem, I think its worth outlining the issues/causes

  • Having CCK 3 installed
  • Selecting unlimited on your imagefield field (changing this to anything else solves the problem)
  • The 'browse' box and 'upload' disappear for the imagefield cck field and only 'Add another item' is present
  • clicking on 'Add another item' causes the above error message to appear in place of the imagefield cck field

As this issue is clearly related to CCK 3 it could be a problem with that not imagefield - any thoughts

markus_petrux’s picture

Project: ImageField » Content Construction Kit (CCK)
Version: 6.x-3.1 » 6.x-3.x-dev
Component: User interface » content_multigroup.module
Status: Active » Needs review

Let me transfer this issue to the CCK queue. I've been able to track the problem. It is caused by the following code in FileField module:

  // Reduce the default number of upload fields to one.
  // CCK will automatically add one more field than necessary.
  if (!isset($form_state['item_count'][$field['field_name']])) {
    $form_state['item_count'][$field['field_name']] = 0;
  }

But that's not incorrect. The issue is that $form_state['item_count'] in CCK3 does not work like in CCK2. A quick workaround would be:

1) Edit cck/includes/content.node_form.inc

2) Apply this mini-patch:

-      $current_item_count = isset($form_state['item_count'][$field_name]) ? $form_state['item_count'][$field_name] : max(1, count($deltas));
+      $current_item_count = max(1, (isset($form_state['item_count'][$field_name]) ? $form_state['item_count'][$field_name] : count($deltas)));
amcc’s picture

works like a charm, many thanks for such a quick response. I was slightly disheartened when i saw that this issue was originally posted in August (shows how choosing your queue helps here).

Its probably worth pointing out to anyone applying this patch manually that its line 161 that needs changing

markus_petrux’s picture

Title: "Add another item" causes Invalid argument supplied for foreach() in <path to CCK module> content.node_form.inc on line 456 » "Add another item" for FileField widgets causes Invalid argument supplied for foreach() in content.node_form.inc on line 456
Status: Needs review » Fixed

Ok, I'm also pretty sure the above mentioned patch fixes the issue. Committed to CVS. ;-)

http://drupal.org/cvs?commit=271078

aries’s picture

Sorry guys, but still not solved.

  1. Edit cck/includes/content.node_form.inc, search for content_multiple_value_form() function.
  2. Apply this:
             $max++;
             $deltas[] = $max;
           }
    +      if (!isset($deltas[0])) {
    +        $deltas[0] = 1;
    +      }
           break;
    
         default:
    

Status: Fixed » Closed (fixed)

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

hendrinx’s picture

FYI - the latest 6.x-3.2 FileField release addresses this problem - works like a charm now

ccshannon’s picture

I'm having this problem using the latest (Dec. 7, 2009) build of CCK 3, using either Filefield 3.0 or 3.2, same issue.

Using Multigroup, I can add new items to the group, but my Imagefield fields (set to Unlimited) I have the 'Add Another Item' button, but cannot actually add anything. Clicking the button I get the throbber thingie, but no additional upload widgets into the field. This is not a problem with any other field or widget. Regular Filefield widget works fine, only affects image widget.

EDIT - Oops, didn't read the full thread title. I think I need to open a new CCK issue, as it's not a JS error.

EDIT 2 - Okay, turned out my problem was using "Imagefield Zip Extract". Disabling that module got my Image widgets working again.