Hide entity IDs in autocomplete text fields

Created on 10 February 2022, almost 3 years ago
Updated 29 April 2024, 8 months ago

Problem/Motivation

Drupal entity autocomplete form widgets automatically append the entity ID to the end of the entity name when you select it (eg: "Tractor" becomes "Tractor (123)". It does this so that when the form is submitted it can look up the entity by ID instead of name (which is more accurate). See attached screenshot.

This is acceptable, most of the time. However it can cause some confusion when you're dealing with entities that have numbers for names. For example, the Season taxonomy may have a term "2022". If you try to reference that in the Planting Quick Form, it will become "2022 (123)" - simply because the entity autocomplete widget tacks that on automatically.

Related core issue: πŸ› UX: Hide entity ID in autocomplete widget Needs work

Proposed resolution

As part of the Planting Quick Form v2 port, I found a JavaScript behavior that seemed to do exactly what we want!

https://borutpiletic.com/article/hide-entity-id-autocomplete-field-widge...

I included this in farmOS via this commit: https://github.com/farmOS/farmOS/commit/3365fc5b23e9b95ebcea8e8e65561196...

Today, however, I discovered that this was causing a critical bug: https://github.com/farmOS/farmOS/issues/502

... so I reverted it: https://github.com/farmOS/farmOS/commit/426ef150e8af80ef4b42a86ed6bf3e91...

But I wonder if we could debug it... maybe the script can be used. I think the problem ultimately lies in the fact that the script was completely REMOVING the ID from the text... It might be better if it HID it, but still passed it through to the server.

Remaining tasks

TBD

✨ Feature request
Status

Active

Version

3.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States m.stenta

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024