I dont know if this a bug for entityreference, field collection or views, but i am posting it here because the warnings i get are from the entityreference module.

I have an entity reference field inside a field collection.
That entity reference field is filtered by an entity reference view. When i press the "add new" or "remove" buttons in the field collection i get these warnings:

Warning: array_flip() expects parameter 1 to be array, null given in entityreference_field_validate() (line 224 of /srv/http/epik/sites/all/modules/entityreference/entityreference.module).
Warning: array_keys() expects parameter 1 to be array, null given in EntityReference_SelectionHandler_Views->validateReferencableEntities() (line 131 of /srv/http/epik/sites/all/modules/entityreference/plugins/selection/EntityReference_SelectionHandler_Views.class.php).
Warning: array_diff_key(): Argument #2 is not an array in entityreference_field_validate() (line 224 of /srv/http/epik/sites/all/modules/entityreference/entityreference.module).
Warning: array_flip() expects parameter 1 to be array, null given in entityreference_field_validate() (line 224 of /srv/http/epik/sites/all/modules/entityreference/entityreference.module).
Warning: array_keys() expects parameter 1 to be array, null given in EntityReference_SelectionHandler_Views->validateReferencableEntities() (line 131 of /srv/http/epik/sites/all/modules/entityreference/plugins/selection/EntityReference_SelectionHandler_Views.class.php).

This causes all of the entity reference fields to lose their values and display only the "none" value.

This only happens when the view contains a contextual filter. If there is no contextual filter everything works fine.

Tested with latest stable and dev versions of views, entity reference, field collection, entity api, php 5.3 and php 5.4

Files: 
CommentFileSizeAuthor
#5 1753774-5_fix_array_param_errors.patch2.11 KBtedfordgif
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es).
[ View ]

Comments

I just found out that the same problem happens when i use an entity reference field filtered by a view inside a relation add form.

IGNORE

Two months already, any solution on this one?

Same problem here -- entity reference field, with contextual view filter. Does not involve field collection module.

Version:7.x-1.x-dev» 7.x-1.0
Status:Active» Needs work
StatusFileSize
new2.11 KB
PASSED: [[SimpleTest]]: [MySQL] 121 pass(es).
[ View ]

Here's a simple patch that addresses the issues for me, but needs more thorough review.

Status:Needs work» Needs review

This fixed it for me. It's a pretty simple change and from what I see it's ready...

I get these warnings and a "An illegal choice was detected. Please contact your administrator" message.
This happens when
1) I have an entity reference field (filtered by views)
2) A date field
3) I use date repeat
4) I select Include dates and add 2 or more dates.

This disappears if i remove the entity reference field. Also this patch does not fix that problem for me.

#5 patch is working good. It removes the warnings of array_flip and array_keys when using entity reference views with dynamic contextual filter.

Status:Needs review» Reviewed & tested by the community

#5 is good.
#7 obviously a different issue.

patch in #5 worked for me.. :)

#5 worked for me to stop the warnings above as well as this one too:
Warning: array_diff_key(): Argument #2 is not an array in entityreference_field_validate()
I applied it to 7.x-1.1

Version:7.x-1.0» 7.x-1.x-dev

This should be fixed in dev.