Using CCK 6.0-3.0-alpha3, if you have a multigroup that doesn't have any required fields, you get some warnings:

Warning: array_keys() expects parameter 1 to be array, null given in _content_multigroup_node_form_after_build() (line 315 of /var/www/ows/fc/sites/all/modules/contrib/cck/modules/content_multigroup/content_multigroup.node_form.inc).
Warning: array_keys() expects parameter 1 to be array, null given in content_multigroup_node_form_pre_render() (line 281 of /var/www/ows/fc/sites/all/modules/contrib/cck/modules/content_multigroup/content_multigroup.node_form.inc).

Working on a patch.

Comments

DeFr’s picture

Title: Warning on node edit form for multigroup without any required field » Warning on node edit form for multigroup without any required fields
Assigned: DeFr » Unassigned
Status: Active » Needs review
StatusFileSize
new712 bytes

Attached patch seems to fix the problem.

tomsm’s picture

Applied the patch, it also solved this issue: http://drupal.org/node/1096776

intyms’s picture

@DeFr
Thank you. The patch works.
(I don't see any more the warnings when i create a new node or when i edit an old one.)

Ela’s picture

Patch in #1 works for me too

mariagwyn’s picture

+1 for patch in #1

jvieille’s picture

patch in #1 works

lanzs’s picture

Thanks for patch! It works for me

realityloop’s picture

Status: Needs review » Reviewed & tested by the community

This resolves the error, so marking RTBC.

giorgosk’s picture

warning gone after applying the patch

christiaan_’s picture

+1 for patch #1.

Thank you very much.

JKey’s picture

+1
Thank you very much!

circuscowboy’s picture

I hope this patch gets committed. I solves the problem for me.

Baudouin’s picture

Patch works for me. Thanks.

pvanerk’s picture

Patch works for me. Thanks!

andreiashu’s picture

Worked for me too. Thanks!

slybud’s picture

+1 for the patch, works for me too !

karlitos’s picture

Thank you very much!!! worked for me too ;-)

Macronomicus’s picture

+1 - Works as advertised.

samiu1287’s picture

Thanks for the patch! Beside the issues on this thread, when I clicked on 'Add more values' for a multigroup fieldtype, I would allways get a 500 error. After applying the patch, everything seems to work as designed. Thanks a lot and someone make sure this patch gets committed.

Morasta’s picture

Many thanks for the patch, did the trick for me.
Just in case anyone is unclear this is for multigroups without a required field. The rest of the form doesn't matter.

Thierry Roffini’s picture

@DeFr
Thanks ;)

jvieille’s picture

Can this patch be committed? This issue shall be closed now

johnnybgoode’s picture

StatusFileSize
new1.73 KB

Edit: alternate patch to the one posted previously - addresses warnings by checking the array before array_keys is called, as opposed to always creating an empty array. First patch may be more efficient but I have not tested enough to determine if there are any side effects.

DeFr’s picture

@#23: We've been running several major sites in production with the patch attached in #1 without any side effect pretty much since the release of CCK alpha3.

The only thing that the patch could broke would be a content type with different fieldgroups with the same name, which can't happen thanks to both the validator and the database structure (the primary key of the content_group table is (type_name, group_name)).

I'd would rather thus stay with the patch in #1, which has been RTBC for some time and is presumably already tested in the wild by all the commenters in this issue.

edwinyn’s picture

Patch #1 works flawlessly on single value. On unlimited values, when I click "Add more values" it says "An error occurred... Call to undefined function content_set_nested_elements() in <b>..\sites\all\modules\cck\modules\content_multigroup\content_multigroup.node_form.inc.."

Anyone?

DeFr’s picture

@edwinyn, #25: content_set_nested_elements is defined in content.module, there's pretty much no way it can be undefined in the JS handler, and it works fine here. Did you only update some part of CCK somehow, like, only the content_multigroup submodule ?

edwinyn’s picture

#26, you are right, I only update the content_multigroup submodule. Currently I am using cck 6.x-2.9 and just want to have a multigroup feature as I've got some error when upgrading cck 6.x-2.9 to 3.0. It says "User warning: Unknown column..." when I tried to re-arrange the fields (I have many fields). Still don't know how to upgrade it instantly.

jlashomb’s picture

The problem is when $form['#multigroup_required_fields'][$group_name] is NULL and not an empty array when used in array_keys. Does it then make sense to just cast that value to an array when using it in the that function?

replace:
array_keys(
with:
array_keys((array)

DeFr’s picture

@jlashomb, #28: Just use patch in #1, which ensures that $form['#multigroup_required_fields'][$group_name] is initialized to an empty array like it was intended to.

@edwinyn, #27: You can't just take part of CCK like that, the landing of Multigroup implied various tweaks to the underlining assumptions made in CCK data storage, which is why a 3.x branch was created. The only difference between CCK 2.x and CCK 3.x are related to multigroup and nested fieldgroup handling, so, in short, if you want to use multigroup, then you want CCK 3. You ran the updates listed in update.php after trying to upgrade to CCK 3 right ? If you did, and you still get a query error, then you should open a new issue.

andreiashu’s picture

Just wanted to add regarding #23: we've been using the patch from #1 for over 1 month now in a few productions sites and never had a problem so (as DeFr already did) I would also recommend to not change it unless someone finds a bug with it.

theatereleven’s picture

I'm receiving HUNK failure messages trying to apply this patch to Drupal 6.22. Any ideas?

giorgosk’s picture

@theatereleven

so you are not succeeding at patch applying
make sure you read the patch section (http://drupal.org/patch)
and you have the right tool to apply the patch

theatereleven’s picture

I tried it again and it said:

Hunk #1 succeeded at 122 with fuzz 1

Not sure what that means, but the patch seemed to have worked as I'm not getting the CCK errors any more.

3rdLOF’s picture

Anyone knows when this patch will be rolled into HEAD or a new dev version?

yngens’s picture

subscribe

chey’s picture

Patch #23 worked for me. I was receiving errors on lines 316 and 281 and this patch fixed the issue.

DeFr’s picture

Posting it once again to avoid confusion: the patch that has been RTBC is the one in #1, not the one in #23. All it's waiting for is feedback and hopefully commit from a CCK maintainer.

sarhansg’s picture

EDIT: I managed to run the patch. However, now when I create multiple entries within a group the content does not get saved. Anyone else experience this?

DeFr’s picture

@sarhansg in #38: More informations on how to reproduce your problem will be needed, because I'm pretty sure someone would have mentioned it by now if they had stumbled upon it. So, is your group a multigroup ? If yes, what are the types of the fields stored in it and how are you creating multiple entries, using the Add more button ? If not, I guess it's only creating multiple entries for a single field that happens to be in a group, so, what's the type of your field, is it nested in a sub-group and does it work if you move it out of the group ?

(I've just played a bit with creating a node with both an unlimited multigroup containing a node reference and a content taxomy field on the one hand, and a simple group with a single nodereference on the other, putting three values in each values in each fields using the Add more button, and the node came out fine here)

sarhansg’s picture

Hi DeFr,

I'm guessing it's an error on my part since no other user reported similar issues. I'm no developer so please bear with me.

I created a multigroup field (Details). This field contains two sub-fields. The first is Date which uses the Date CCK field type and the other is Amount which uses the Money CCK field type.

Details field is set to "required" and "unlimited" whereas the sub-fields are set to "not required" (unchecked) and "1".

There's only one "add another item" shown within the fieldset.

Hope this helps. Let me know if you require any additional information.

DeFr’s picture

@sarhansg in #40 : Huum, I've just tried to setup a new instance to try to replicate your problem, but it seems to be working fine here. Attached is an export of the Page content type with your multigroup added. What are you filling in the different fields, and what do you mean exactly by "the content does not get saved" ? Do you get the node form back, with a validation error, in which case that might be linked to #1126930: Validate error for not mandatory field ? Or do you get to the node page view, but without the values you've added ?

sarhansg’s picture

What I meant by "the content does not get saved" is that the additional values (in the multigroup fieldset) do not appear in the node page value. Only the first value does. When I try editing the content again the additional values are no longer available. Hope this helps detect the problem.

ofktoubro’s picture

#1 worked for me as well

yched’s picture

Committed. Thanks !

DeFr’s picture

Status: Reviewed & tested by the community » Fixed

Moving to fixed accordingly.

@sarhansg: If you still have an issue with your content type, I think you should open a new issue. Ideally if you can, attach an export of your content type (you can get one with the Content Copy module that's bundled with CCK), which will make it easier to try and reproduce your problem.

Status: Fixed » Closed (fixed)

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

emcniece’s picture

For what it's worth, I'm still hitting this issue. 6.x-3.0-alpha3, packed on 2011-03-17. I just opened content_multigroup.node_form.inc and rolled down to line 122, and saw that this patch was already applied. Might have been me in the past, not totally sure, but the point is the error still shows up.

No further info!

DeFr’s picture

@#47: The patch was commited in August, there's just no way for it to be in the alpha3 release packaged in March... (Commit )

Given the amount of people reporting that the patch fixed the issue for them, and the fact that we've been running in production with this patch for 9+ month, I'm rather sure that the patch fixes the warning. Either you didn't apply the patch correctly, (line 122 is only the start of the context, the line is actually added at line 125) or your running into a different issue. It should be pretty easy to check: the only commit in the 6.x-3.x branch since 6.x-3.0-alpha3 is the one for this issue, so you can download the 6.x-3.x-dev release and get just this fix.

chilic’s picture

Thank you. The patch works.

emcniece’s picture

@#48

I was running cck 2.9 :|

Thanks for your help.