I have a field of type entity reference. Number of values is set to unlimited. But I want to make sure that a user does not reference the same entity twice. I am sure this is a use case that has been encountered before. What is the best way to accomplish this?

Comments

Anyone?

I'm also in need of this functionality. Have you found a solution yet?

The second part of my problem is that I would like to accomplish this by making a multi-select list where only the entities appear that haven't been referenced yet. Is there someone who has an idea how to accomplish this?

Ok, If your entity reference field is on a Node entity (Content type) you can use unique field module. It will still show referenced entities in the options but will fail validation, meaning will not let you save it.

Unique field does not work, or at least did not form me, when the entity reference field is on the User or entities other than node.

HTH

Version:7.x-1.0-rc1» 7.x-1.x-dev
Status:Active» Fixed

you can use entityreference_view_widget. See the project page for an explanation for "Exclude" items.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Active

jonhattan:
ERVW doesn't solve the problem, only hides it.
Has anyone found a way to enforce uniqueness in a multi-valued ER field?

Also, re Unique Field:
I would rather not have user's input fail validation when they choose duplicate values.
Rather, I would rather have a processing function that unique-ifies the values on submit.