I have seen that this module is not tested against Entity Reference fields. I have created a group with two fields that have cardinality unlimited. One of the two fields is an entity reference field, with autocomplete input. It seems that the module works, however when I visit the new content form I get the following notices:

Notice: Undefined index: target_id in entityreference_field_widget_form() (line 821 of sites\all\modules\entityreference\entityreference.module)

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

The warnings are not present when I visit the edit content form, maybe they appear when the fields are empty?

Comments

plessas’s picture

Issue summary: View changes
adamtong’s picture

i have same issue too!

nesse0’s picture

I have the same issue on add and edit forms. Entity reference fields are extremely common so I would think this is a fairly high priority issue.

nesse0’s picture

So I've narrowed this down to an issue with entity reference fields with cardinality >1 that use the autocomplete widget.

I found a related issue over at the issue queue for the entityreference module: Entity Reference Error (array_flip, undefined target_id) when using autocomplete and no entites selected

Applying the patch in comment 3 from there resolved the issue for me.

alvar0hurtad0’s picture

Great @nesse() !!

Yo you dare to write a patch?

;)

I promise correct author attribution.

:)

nesse0’s picture

alvar0hurtad0, I think the existing patch for the entity reference module is the solution rather attempting to resolve it within this module.