Postponed
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
3 Jun 2013 at 04:37 UTC
Updated:
27 Jan 2020 at 04:02 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
eugene.ilyin commentedSorry, it's wrong patch. Don't use it.
Comment #2
eugene.ilyin commentedIf you will approve my patch, please specify me as author of the commit.
Comment #3
amitaibuWhat's the use case?
Comment #4
eugene.ilyin commentedFor example:
We have entity reference field with multiple values for display related articles of main article. Will be good to avoid duplicates in this field automatically.
Comment #5
eugene.ilyin commentedWhat you think about it? I think it's very convenient.
Comment #6
eugene.ilyin commentedAny news?
Comment #7
eugene.ilyin commentedHello.
Can you commit my patch please? It's very usefull.
Comment #8
melchior commentedHot!
Please commit this patch.
It would be nice if there could be a silent mode that auto-removes the value instead of marking it red.
thx!
Comment #9
amitaibuThis feature needs to be created against D8, and backported to D7. Anyway, I think it can live in contrib and not in ER-core.
Comment #10
eugene.ilyin commentedYou suggesting me to create separate module for this little functionality?
Comment #11
amitaibu> You suggesting me to create separate module for this little functionality?
Or try to push it in D8, and then we can backport it to D7.
Comment #12
eugene.ilyin commentedAs I see entity_reference for D8 has been included into core. I should write patch for this module in core? I think that it will be very difficult and I will wait year, until it will be approved :(
Comment #12.0
eugene.ilyin commentedadd tag for image
Comment #13
hedgefrog commentedI would find this very useful - could it be committed in D7 as it is?
eugen.ilyin doesn't seem willing to create it for D8?
Comment #14
eugene.ilyin commentedI asked in #12. Should I prepare this patch for d8 version of this project, or for entity_reference in D8 core?
Comment #15
eugene.ilyin commentedPlease answer to me
Comment #16
manuelBS commentedBy the way, there is a module for that: https://drupal.org/project/entityreference_unique
Comment #17
codesidekick commentedentityreference_unique doesn't export to Features and is pretty poor in terms of coding standards. I think this is something that should be included as part of the module.
Comment #18
shiraz dindarI don't understand what the "Forbid Duplicates" entity reference field option is even for if it doesn't do anything without this patch. I too think this should be rolled into D7. It works for me.
Comment #19
toddwoof commentedMaybe this is a Feeds issue -- but neither this patch nor the module referenced in #16 works when importing content using Feeds. With "Forbid duplicates" checked (or the corresponding checkbox for the module), multiple imports results in multiple identical references in a given field.
Comment #20
rusticdoozy commentedWhy not use a view which can produce a filtered list with no duplicates and then use the view as filter itself in entity reference field settings?
Comment #21
maxilein commentedWell using D8: by mistake I added the same title twice. Now I cannot save that nodes...
Drupal\Core\Entity\EntityStorageException: Unable to remove item at non-existing index. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->delete() (line 718 of /core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
That is why this is a good option!
Comment #22
toddwoof commented@rusticdoozy: That wouldn't allow new values to be imported.
Comment #23
kris77 commented@eugene.ilyin i tried your patch but same doesn't work with field collection.
This my scenario:
In my ER1 i select checkbox" Forbid duplicates".
So, when i visit page to create my entityform type(FORM1)
Comment #24
Rafal LukawieckiI also have a use case for this feature. We are using entity references to create something similar to a table of content, and it would be useful to prevent a node from being added more than once to its "parent" (in terms of ToC).
The autocomplete widget in the entity reference module is very useful for us, but, unfortunately, it lists nodes that have already been referenced, and so allows for erroneous entries to be made. This feature would prevent those errors. Any plans to have this patch committed to the module?
Comment #25
xlin commentedAttached patch to remove duplicates on save rather than validate. DO NOT use this patch if you want to inform your user that hey make a mistake.
Comment #26
xlin commentedRe-use the checkbox option provided by @eugene.ilyin.
Comment #27
joshua.boltz commentedIs there an existing Drupal 8 issue around this? I could also see this being a useful feature, as editors can easily add the same referenced entities in the multi-valued entity reference autocomplete widget.
It would be nice to either:
1) provide the user an error message when saving the entity that contains the ER field to tell them they added duplicates and they should fix it before the form can be saved
2) validation after entering a referenced entity that is already added to the field (instant feedback to the user)
Comment #28
delacosta456 commentedhi
having this directly tied in Entityreference could be interested and reduce time wasting for workaround like building a views..
About workaround i think entityreference_view_widget and references_dialog are some modules that could help avoiding duplicate in multified of entityrefence ...
The entityreference_view_widget has a visual documentation giving more understanding HERE