Notice: Undefined variable: instance in field_collection_field_widget_embed_validate() (line 1495 of d7/modules/all/field_collection/field_collection.module).

I have a redhen install.

I get this error when:
1. create a relatio
2. add a field collection
3. place a term ref in that field collection
4. make it required or manditory
5. add the relation

When the save button on the contact page is hit, the error comes up.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

SocialNicheGuru created an issue. See original summary.

SocialNicheGuru’s picture

Issue summary: View changes
knalstaaf’s picture

I'm getting this with a simple Field Collection field (that's being triggered by a conditional field based on a taxonomy term selected with a list - each term triggers a specific Field Collection field), only containing an (existing) image field and a body field. It occurs when I'm uploading an image.

Edit: I think I figured out what's triggering this error. I have a (required) Field Collection field containing two fields: an image field and a body field <- both required fields as well.
When I upload an image first, the error appears. When I fill out some body text first, and upload an image afterward it does not appear. So it has probably something to do with the validation of required fields.

This behaviour ceases when you make the fields within your Field Collection no longer required.

Road Kill’s picture

I am getting this error using 7.x-1.0-beta11+9-dev when I remove an image from an image field that originates from a field collection.
I can also confirm that enabling or disabling required does not solve the problem.

jamsilver’s picture

Status: Active » Needs review
FileSize
616 bytes

Looks like there's a typo in the code. Looking in the wrong variable for the field instance label. Patch attached.

As a plus, this should fix the form validation error message, which presumably is currently missing the field label.

jmuzz’s picture

Status: Needs review » Closed (duplicate)

Thanks @jamsilver.

This fix was proposed in #1289062: Required fields in collection not validated when empty which originally introduced the bug. I'll commit it soon.