When a user fills in a valid term/name/title/value in an autocomplete reference field it becomes an empty reference.
It only works when a ajax callback supplied value is chosen.

Also see #1389238: Autocomplete widget improvements

Comments

haydeniv’s picture

Would it be best to offer the user an "Add [Entity Name]" option to the auto complete when a suitable entity cannot be found. When you click on that it pops up the entity add form to be filled out. I don't think we can just let them free tag as there may be other required fields that need values to create an entity.

Of course that turns out to be a ton of ajax and validation/accessibility nightmare. Also good luck getting this to work on non-js enabled browsers.

Just some thoughts.

JvE’s picture

Hm, maybe I have not been clear enough in the problem description.

The issue is that if you type in a label for an entity *that does exist* then the entityreference autocomplete widget will act as though you typed nothing. It is not about creating entities if they do not yet exist.

only when you choose one of the autocomplete suggested vales or type in the entity id in parentheses will it work.

So with javascript disabled the current entityreference autocomplete widget does nothing at all.

haydeniv’s picture

So are you saying that entity reference should try and find a matching entity if no entity id is specified and use that as the value?

If so what should happen when there are multiple entities with the same title?

JvE’s picture

Either use the first one or throw an error.

In my opinion anything is better than just silently throwing away the value typed by the user.

The current behaviour of the autocomplete does not deal with multiple entities with the same title either.
It will take the one you select but you have no way of telling from the displayed values which one you're selecting.

jax_rox’s picture

Few months old, but I agree. Is it possible to have it save the user-inputted data as just a text entry if no referenced entity is selected? Would be better than simply discarding without explanation.

JvE’s picture

@jax_rox: work is being done to get this fixed in #1389238: Autocomplete widget improvements If you could help test the patches there it would be appreciated.

damien tournoud’s picture

Status: Active » Closed (duplicate)

If I'm not mistaken, this has been dealt with in #1389238: Autocomplete widget improvements.