In my particular case, I have a node edit form that can be related to other nodes of a different type. Selecting the associated entity is accomplished using Inline Entity Form widget (multiple values).

The problem is, a user never knows if the child entity exists. Therefore, associating it is always a multi-step process, because they have to use "Add Existing" to search for duplicates before they click "Add New" to add the new one:

  1. Always click on "Add Existing"
  2. Type in the title to search for
  3. If the Entity is found, finish; else, click "Cancel"
  4. Click on "Add New"
  5. Type in the title you just typed in, fill out the rest of the node fields, and click "Save"

This potetially five-step process could be made into a two-step process:

  1. Type in the title and wait for autocomplete. If found, click "Save"; else, the autocomplete form expands to reveal the inline node entry form with the title pre-filled
  2. type in the node fields and click "Save"

The "Add New" and "Add Existing" buttons are unnecessary in this type of a use case. If an entity already exists, it's logical to assume that the user wants to associate it, rather than create a duplicate. If an entity is not found, it's logical to assume that the user would like to create one with the information they just typed in.

The configuration settings for this new feature could be accomplished by creating a "Automatically create unique entities" option under "Allow users to add existing nodes". This option would hide the "Add" buttons, and enable the operation as per above.

#2 2013.06.23-iefcombined.png13.16 KBmicromegas
Members fund testing for the Drupal project. Drupal Association Learn more


bojanz’s picture

Category: feature » support
Status: Active » Fixed

This is completely different from the way IEF works now, so I think it would make more sense as a new widget in a separate module.
You could also try Entity Connect as an alternative.

micromegas’s picture

Category: support » feature
Status: Fixed » Active
13.16 KB

I revised the idea--see the attached mockup.

The only difference from the current operation is that the combined field would have the autocomplete open by default--"Add Existing" would be greyed out until the user has selected an option from the autocomplete. It just saves the user from having to click "Add Existing", type, click "Cancel", click "Add New", and re-type the value when they don't know if the node exists already--a common situation for many sites that use this module.

The only sticking point would be having the title auto-populate after they click "Add New", since the title field may be hidden by the likes of Automatic Entity Label... but in this case, the value would be overwritten anyway, correct?

Do you think this would be reasonable to accomplish with the current internals of IEF? I can work on it, but I would appreciate any guidance/hints before I start.

micromegas’s picture

Also see where other site builders had a similar requirement.

I think for the sake of simplicity, this is best implemented as a separate widget, so you would have IEF choices of "Single, Multiple, and Combined" so as not to disturb those who are already using the other widgets.

bojanz’s picture

That definitely needs to be a new widget, possibly in its own module that depends on IEF.
However, it is close enough to how Entity Connect works that I'm not sure it makes a lot of sense for you to spend time on it.

In any case, keep us updated on your next steps.

tonystar’s picture

IMHO, it should not be the separate widget but one additional setting.

It could be called "Default behavior" with the following possible values:
- Display "Create new" and "Choose existing" buttons
- Create new entity
- Choose existing entity

In the current implementation of IEF: the second option is used in single widget and the first option is used in multiple widget.

So it will be possible to support backward compatibility with such setting.

philsward’s picture

I agree with tony's approach in #5. I just threw on IEF to check it out and was rather disappointed that it really only goes one way: Create a new product. What if I've bulk created a bunch of products already and need to reference them to a node? I love how IEF shows the existing products that are referenced and would love to use this, but it looks like I'm stuck with the autocomplete widget.

I'll check out the entity connect module, but I hate installing 5 different modules just to get rid of one "livable" step to my workflow. :-/

philsward’s picture

Just checked out Entity Connect and it won't work out-of-the-box on DC without a bunch of custom monkey motion, something I am incapable of doing...

From what I can tell, it is the direction you are suggesting @bojanz but unfortunately isn't the solution.

micromegas’s picture

@tonystar #5: in my particular case, this approach wouldn't have any benefit, since I need a 'multiple values' widget that combines all three behaviors in one. Assuming IEF has some plugin functionality or classes that can be overridden, I'd like this to be a completely separate widget in a completely separate module, as bojanz said.

Keep in mind, you can get a similar functionality now by using Entity Connect on an ER autocomplete field--it just doesn't have some of the benefits of IEF, such as the inline form and only creating the child entity when the parent is saved.

@philsward #6: did you check the 'allow users to add existing nodes' box on the field settings page? IEF definitely has the ability to reference existing nodes; you may have to use the 'multiple values' widget to get it to work the way you'd expect.

@philsward #7: I agree, see for another discussion regarding all of these different Entity Reference widgets (Entity Connect, IEF, References Dialog), of which we have three modules, but none that are a complete solution--I believe IEF is the best candidate to focus our efforts on.

That being said, for my current project, this is a 'nice to have' and not a 'needs to have', so I don't plan on working on it for several weeks.

philsward’s picture

@micromegas looks like I missed that option... I'll take another look and thanks for the heads up :-)

philsward’s picture

@micromegas - checked it out and got it working. Only thing I don't like is that the multivalue existing only takes one product at a time. Any way to set it up to accept the comma separated list of product and add them all at the same time? :-)

While trying to add 31 products to a Display using IEF, the browser crashed around adding product 20 and had to do it all over... (The second go around, I just switched the widget back to the normal autocomplete to get the products referenced in one shot)

micromegas’s picture

I've started working on this in a sandbox at

One approach is to create an entirely new widget within a separate module, by modifying the IEF widget hooks and then using the existing IEF functions and controller class. Another approach is to use hook_field_widget_WIDGET_TYPE_form_alter() to modify the existing Multiple widget form. Currently I'm experimenting with the first approach.

bojanz’s picture

The first approach is definitely better.

bojanz’s picture

Issue summary: View changes
Status: Active » Postponed

Since this is a major UI change, I am postponing it for the next branch just like I did #1881616: Move the inline forms (add, edit, remove, reference existing) to modals.
In the meantime someone can implement the desired widget in another module that depends on IEF.

danielphenry’s picture

I would love to see this feature. From a usability standpoint it makes way more sense than the current. workflow. If the user chooses to add or create widget it doesn't make sense to force them to press a button to search. It's just a wasted and unnecesary click. It provides no performance advantage either. Can this feature be reconsidered?

bojanz’s picture

Status: Postponed » Closed (duplicate)

Continued in #2673548: Prioritize 'add existing' in nested entity creation UX to prevent duplication.. If this is going to happen, it's going to happen in the D8 version.