I've found that the dev release of field_collection fixes one issue I had with the beta4. But it also has one more bug but it was easy to fix. The setup has nothing spectacular, only i18n activated with some of the submodules, no special configuration.
Here is the message I have if I edit a node with a field collection:
Notice: Undefined index: en in field_collection_field_attach_form() (line 1142 of .../sites/all/modules/field_collection/field_collection.module).
Eventually the field in question does not have a specific language and is simply "und" instead of "en". Using the field_language function to get the proper langcode to use fixes the issue.
patch following
Comment | File | Size | Author |
---|---|---|---|
#20 | undefined_langcode-1716526-20.patch | 1.82 KB | ericpoir |
#15 | undefined_langcode-1716526-15.patch | 2.24 KB | japerry |
|
Comments
Comment #1
idflood CreditAttribution: idflood commentedComment #2
idflood CreditAttribution: idflood commentedFound one more issue at the same spot if the field processed is a "container". Here is the notice displayed:
Notice : Undefined offset: 0 dans field_collection_field_attach_form() (ligne 1143 dans .../sites/all/modules/field_collection/field_collection.module).
In this situation the $lang variable is set to FALSE so I added it to the condition.
Comment #3
gmclelland CreditAttribution: gmclelland commented#2: undefined_langcode-1716526-2.patch queued for re-testing.
Comment #6
gmclelland CreditAttribution: gmclelland commentedI'm seeing this as well. In my case, I think it is when I'm using http://drupal.org/project/fape to edit a field that is attached to a node.
Can you re-roll your patch?
Comment #7
Jelle_SAlso, there should be a check if the field exists in the form, developers can call field_attach_form with a value for 'field_name' in the options argument, if so it is possible that a field is not present:
Comment #8
super_romeo CreditAttribution: super_romeo commented#7 - same thing
Comment #9
kle CreditAttribution: kle commented#7 - same issue
Solution is simple: Change this in field_collection_field_attach_form():
to
Comment #10
Barry_Fisher CreditAttribution: Barry_Fisher commentedThanks kle
Following on from #9 I've rolled a patch adding the
&& isset($form[$field_name]
against 7.x-1.0-beta8 which works for me.Comment #11
Chris Burge CreditAttribution: Chris Burge commented#10 resolved the issue for me. In my case, the field didn't exist, which caused the error.
Comment #12
japerryThe patch in #10 doesn't fully get all the if statements. This following patch adds checks at the top of the loop, which skips looking in the field if none of the conditions are met.
Comment #13
shi99 CreditAttribution: shi99 commentedThe patch in #12 solved the issue for me.
Thanks
Comment #14
ybabel CreditAttribution: ybabel commentedPatch #12 works fine but do not apply any more (the lines have changed position 1009 -> 1226)
Comment #15
japerryHere is a re-roll against HEAD as of 2/2/2017. It also works against beta12.
Comment #16
tobiberlinI applied that patch against 7.x-1.0-beta12 version and it works like a charme
Comment #17
tobiberlinUnfortunately I found out that it does not solve the issue. I create a form in the following way:
It seems that field_collection_field_attach_form() still acts on fields and field collections which should never be added to the form. After applying the patch following error messages appear:
They repeat in different order. The node type I want to get the fields from, has some field groups/ collections and fields in it.
Comment #18
tobiberlinI found out the problem was in another hook_field_attach_form: https://www.drupal.org/node/2890683
Comment #19
Chris Burge CreditAttribution: Chris Burge commentedPatch no longer applies to HEAD.
Comment #20
ericpoir CreditAttribution: ericpoir commentedI created undefined_langcode-1716526-20.patch to make it work with the current version of the module.