Read through other issues regading cck and the manage images tab but couldn't find any similar issues so...

Using latest NG 3.x-dev (8 march 2011) and tested with CCK (both 6.x-2.9 and 6.x-3.0-alpha1) both unlimited and limited value fields, text and user-reference, only added to the Photo content type.

Multi value CCK fields are breaking on the Manage Images tab. Only fields belonging to the first image are draggable and it's not possible to add a field and save their values.

Clicking on "add another item" generates the following error message:

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

I've also reproduced it on a clean install.

Attached a screenshot which should be a bit more clear.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scroogie’s picture

Okay, damn, something must have changed in the field handling of CCK. The error message seems to be related to the field deltas, but we will have to debug this. Unfortunately, I don't have XDebug setup properly here right now. Perhaps for 3.0, we should document that we don't support multiple value fields currently.

andreas_jonsson’s picture

This patch seems to try to address this issue partially (patch attached), but doesn't fix it in node_gallery's case:

"Make several cck edit forms on one page work"
http://drupal.org/node/1037460
That issue was created in relation to the editview module which also does multiple node editing on one page.

It seems like multivalue cck fields aren't given unique values in the manage images tab.
Single value field have unique numbers like #edit-images-44-edit-form-title-wrapper but multi-value only have #field_single_field_test_values, so there are loads of duplicate id's across the page.

scroogie’s picture

This is more complicated than I thought. I'll have to take a closer look at editview. The callbacks directly use the fieldname, which is of course not unique on our manage images page. It also retrieves the form from the cache, submits the node form, etc. This wil take some time to fix.

andreas_jonsson’s picture

Seems like this is a recurring problem for many modules trying to implement this functionality:
(editablefields module) #972044: Fully support multi-valued CCK fields

scroogie’s picture

I found a way to fix this, by implementing our own AHAH callback, but didn't have enough time today to finish it. Will probably take til next weekend until I can upload the patch.

scroogie’s picture

I didn't finish the patch yet, but for anyone who's interested:

http://drupalcode.org/project/cck.git/blob/refs/heads/6.x-2.x:/includes/...

Here the function content_add_more_js() is called by the AHAH handler. $_POST contains all current form values (submitted through javascript). The problem is that this code asserts that for every field with the name $field_name, a value in $form, $form_state and $_POST exists. In our case, this is not true, because the values are in $form['images'][$nid]['edit_form'], etc. That, and some additional problems like uniqueness of identifiers, CSS selectors, and so on.

I mastered that already, as the next step I need some re-structuring of functions. Because the form is also rebuilt, I need to apply the same transformations like in the original form. This is what I'm working on right now , beside some javascript issues.

Even if I finish this, I'm not sure that it will be included in 3.0. We might consider disabling multi-value fields for 3.0 and incorporate the patch for 3.1, to allow for more testing. Of course, this process can be pushed by community reviews once I finished the first version of the patch!

dddave’s picture

as soon as your patch lands I am going to test the crap out of it. ;)

scroogie’s picture

Well, the patch got a bit bigger than usual. I doub't that its ready, but I'd like some feedback. I made a second commit locally, because I found a bug in the author field as well. You'll probably have to apply that one first so that the second patch applies cleanly.

dddave’s picture

Jesus, ultra-long patch names...

First findings:

1. Patches apply more or less cleanly.

2. Using a multivalue textfield (set to unlimited) which produced the error described in the OP, now works. I can rearrange, add values and add other items.

Now testing with other scenarios.

Follow-up:

Tested with other fields/unlimited or set to certain numbers/ rearranged/ seems to work on every position. Rotated such images, created lots of different tasks on the manage images screen. So far everything seems to be working fine. I am suspicious but will retire for tonight.

scroogie’s picture

I guess you'll see more patch names like that from now on, it's git that creates those (its the commit message). ;)

Thanks for testing!

andreas_jonsson’s picture

Looks very promising. Will also give this a thorough run in the morning!

scroogie’s picture

Found any bugs?

scroogie’s picture

Status: Needs work » Fixed

Commited to dev and included in alpha3, as it shouldn't touch any functionality that wasn't broken before.

Status: Fixed » Closed (fixed)

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