Errors with unlimited value field

drewish - May 19, 2009 - 18:30
Project:Comment CCK
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

I was testing this module out with an unlimited value CCK user reference field and got the following errors after clicking the "Add another item" button:

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

It also lost the value. The screen shot shows the errors as a result of the AJAX operation.

AttachmentSize
Picture 4.png59.05 KB

#1

drewish - May 19, 2009 - 20:58
Title:Errors with unlimited userreference field» Errors with unlimited value field

Had a little more time to look into this and it's due to the CCK fields being grouped under $_POST['comment_cck'] rather than in $_POST. Not sure what the best solution would be. I guess the options are:
* replicate content_add_more_js(), add a menu item for it, and alter the form to have comment cck fields use that instead. This seems likely to work but a huge pain in the butt.
* move the cck fields up to the root of the form or maybe through some #tree trickery. I kind of see this likely to need other changes to the comment_cck module but perhaps we could avoid duplicating parts of CCK.

#2

drewish - May 19, 2009 - 22:24
Status:active» needs review

Okay so removing the #tree seemed to do the trick. Though in the process I noticed that _comment_cck_ungroup_fields() seems kind of broken. It doesn't return anything if you don't have fieldgroup.module enabled. I made a few changes there and this seems to work fine now.

AttachmentSize
comment_cck_467260.patch 2.92 KB

#3

drewish - May 19, 2009 - 22:26

small tweak, rather than just commenting out the #tree line we need to remove it.

AttachmentSize
comment_cck_467260.patch 2.92 KB

#4

opensanta - May 22, 2009 - 04:53
Status:needs review» needs work

I tested the patch in #3 twice on an existing dev site. Each time, the comment_cck functionality stopped working. When I changed it back to the beta2 ver, the functionality worked again.

There are no multi-valued fields in my content type.

#5

drewish - May 24, 2009 - 08:00

could you provide some more feed back on what doesn't work? here's a re-roll against HEAD.

AttachmentSize
comment_cck_467260.patch 2.92 KB
 
 

Drupal is a registered trademark of Dries Buytaert.