When editing an empty entityreference field as autocomplete:

Warning: Invalid argument supplied for foreach() in entityreference_field_widget_form()
Files: 
CommentFileSizeAuthor
#5 1522172_er-warning_5.patch599 bytesjrbeeman
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]
#1 0001-fixed-1522172-Invalid-argument-supplied-for-foreach.patch798 bytesaxel.rutz
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es).
[ View ]

Comments

Issue summary:View changes

correction

Status:Active» Needs review
StatusFileSize
new798 bytes
PASSED: [[SimpleTest]]: [MySQL] 66 pass(es).
[ View ]

we need a simple patch like this to prevent foreach eating NULL values.

Patch from #1 appears to work.

Status:Needs review» Closed (cannot reproduce)

Sorry for the late reply... :)
Seems to be already resolved.

Is there a reason this patch was never applied. I am migrating one of our drupal sites and noticed that a developer had this patch code in our entityreference.module. Looking in the source repository, I don't see the fix merged in anywhere. Is it necessary? If so can the patch be applied in the next release?
Thanks

Title:"Invalid argument supplied for foreach"Invalid argument supplied for foreach in entityreference_field_widget_form()
Status:Closed (cannot reproduce)» Needs review
StatusFileSize
new599 bytes
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

Re-opening as we ran into this issue during a Commons sprint. Commons uses a combination of OG, Entity Reference Prepopulate, and Entity Reference. In cases where a prepopulate argument isn't passed in the URL, we receive this warning. I believe the fix is simple: Don't assume $items has a value. Patch attached against 7.x-1.x.

facing the same issue..

Was receiving same error on creation of node where a prepopulate argument isn't passed in the URL.

Patch in #5 seems to work well.

Thank you for working on this.

Ditto daniel-san.

My guess is whatever is calling that function is suppose to be passing in $items an array and that the error may be from the calling function instead. Not experiencing this error so haven't looked inot

Issue summary:View changes

correction