EntityAutocomplete form element allows multiple values when #tags is FALSE

Created on 22 March 2016, over 8 years ago
Updated 24 May 2023, over 1 year ago

When you have an entity_autocomplete form element (not talking about field widget here) with '#tags' => FALSE, then it should only accept a single value. There are actually two issues here, but I'm combining them because they're so closely related:

Problem

  1. The autocomplete works the same as if #tags were TRUE. So if you type in a comma and another letter, it's going to autocomplete that, which suggests to the user that you can enter multiple items.
  2. When multiple values are actually supplied, the form element takes it upon itself to choose one of them as the correct value and drops the rest. (It chooses the last one entered.) However, there's no way that the form element can know which of the values is actually the one that should be used.

Proposed solution

  1. Do not autocomplete past the first item.
  2. Add a form error if multiple values were entered.
πŸ› Bug report
Status

Needs work

Version

9.5

Component
FormΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States kevin.dutra

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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