Problem/Motivation

This module is great for adding an inline workflow for referenced entities! The only thing it is missing (and a current problem I have) is being able to add duplicate references. So I have a need to reference an existing entity more than once. This is kind of awkward to override from outside of IEF.

Proposed resolution

Add a field instance setting to 'allow duplicates'. This can be opt-in only so the current behaviour remains unchanged. This just needs to be checked in a couple of places for this to work properly - When showing referenced entities in the IEF field widget form, and when validating the widget form (inline_entity_form_reference_form_validate).

Remaining tasks

User interface changes

One new option when creating a field instance.

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Status: Active » Needs review
FileSize
3.54 KB
ndewhurst’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
5.02 KB

@damiankloip, thanks! I was looking for exactly the same functionality, and I almost submitted a separate issue/patch before finding this.
I updated your patch to work with the latest module code and made a few tweaks:

  • Using the same method for loading the previously selected entities regardless of whether duplicate support is enabled. This seems like a better UX (show any duplicates that may already exist, then show a validation error if the field settings have changed since the dupe was added), doesn't change execution time much, and reduces code length a bit.
  • Fixing the validation code to check the allow_duplicates setting instead of the delete_references setting.
  • For admins who have permission to edit the relevant field settings, add more info to the validation/error message, including a link to the field config page.

This is working well for me. I'm tempted to RTBC this, but it would be good to get more testing/corroboration.

ndewhurst’s picture

Status: Reviewed & tested by the community » Needs review

The last submitted patch, 1: 2376679.patch, failed testing. View results

Status: Needs review » Needs work
ndewhurst’s picture

Removing newer array syntax.

Status: Needs review » Needs work

The last submitted patch, 6: inline_entity_form-allow_duplicate_references-2376679-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.