Hi, I'm really glad to have found this module besides using basic tables. I currently have an entity reference that I need to reference a user ID. However, when placing into the field groups table, I get this error:

Notice: Undefined index: target_id in entityreference_field_widget_form()(line 670 of /home/../modules/entityreference/entityreference.module).

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load()(line 178 of /home/.../includes/entity.inc).

Any ideas?

Files: 
CommentFileSizeAuthor
#3 1683964_entity_reference_empty_entity_ids-3.patch1.61 KBhefox
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

Comments

Project:Field group multiple» Entity reference
Version:7.x-1.0-alpha11» 7.x-1.x-dev

i saw this error on an add content page (node/add/CONTENT_TYPE) with an entity reference field.

the error went away after i visited the admin page for the entity reference field that seemed to be causing the error, in my case: admin/structure/types/manage/CONTENT_TYPE/fields/ENTITY_REFERENCE_FIELD

the content type fields were defined by a features module. i had created the features module on another site where i ran a D6 upgrade that converted node reference fields to entity reference fields. i needed to migrate content type fields from one db to another in order to build the site on a fresh install of commons 3.

everything seems to be working as expected on my site, so i've assumed this to be resolved.

Version:7.x-1.x-dev» 7.x-1.0
Category:support» bug

I had the same problem within a multiple fieldgroup - I think it was to do with the cardinality; when I changed the widget type from autocomplete to select list the error went away, and I assumed it was because the number of entries needs to be "unlimited" to work the same as the other fields in the group.

Title:Entity Reference ErrorEntity Reference Error (array_flip, undefined target_id) when using autocomplete and no entites selected
Status:Active» Needs review
StatusFileSize
new1.61 KB
PASSED: [[SimpleTest]]: [MySQL] 119 pass(es).
[ View ]

tis calling entity_load on an array(0 => NULL) array, thus the array_flip errrors.

Status:Needs review» Needs work

The last submitted patch, 1683964_entity_reference_empty_entity_ids-3.patch, failed testing.

Status:Needs work» Needs review

test failure makes no sense; undeinfed function??

Status:Needs review» Reviewed & tested by the community

Looks good. This fixes one of the notices reported in #2073501: PHP notices when changing to non-existing project in 'create issue' form.

the error went away after i visited the admin page for the entity reference field that seemed to be causing the error, in my case: admin/structure/types/manage/CONTENT_TYPE/fields/ENTITY_REFERENCE_FIELD

Thanks for that, I had the same situation, and yes, that cleaned it up.

I can also confirm that this patch makes the error not appear - even from a fresh re-install that was triggering it for me.
+1 rtbc

Status:Reviewed & tested by the community» Needs work

Needs work:

(1) 0 is a valid entity ID (think: it's the anonymous user), so empty() is not right here, I suppose isset() could be a valid choice
(2) This error message is just the sign of a bug elsewhere (because an entityreference target id cannot be validly NULL, see entityreference_field_is_empty())... if you hide the error under the carpet, you are never going to actually fix it bug.

FWIW, the bug is replicable by using the D6-7 upgrade path.

* A D6 nodereference field is migrated to D7.
* Then the additional nodereference->entityreference conversion is done.
* At this point, the content *looks* stable, and existing content can be edited.
* But creating a new item, if no other admin refinement has happened, causes this fatal error.

In the normal course of events, we usually edit the content type field and display options before putting a D6-D7 converted site into use, so this issue dissolves. However, I've been running a fully-automated upgrade that feeds into user testing directly, and therefore this issue does re-occur for me.

I'm hoping that as our upgrade path is refined that a resave of the content type triggered from a 'features' update will smooth this out. But as is stands, this error at least can be replicated without too much work.

Status:Needs work» Postponed (maintainer needs more info)

@dman: so it's a problem in your migration path?

I had it occur on a completely new install