Entity reference field pre-populates first available entity when using Select (ActiveTags) widget on required fields

Created on 15 August 2025, about 1 month ago

Problem/Motivation

When using the "Select (ActiveTags)" widget for an entity reference field, any field marked as required is automatically pre-populated with the first available entity from the selectable list. This happens even when the field is initially empty.

Expected behavior:
Required fields should remain empty by default. No entity should be pre-selected automatically.

Actual behavior:
The first entity in the selectable list is automatically pre-populated in the form.

Steps to reproduce

  1. Create an entity reference field on an entity type.
  2. Set the field as required.
  3. Select Select (ActiveTags) as the widget.
  4. Open the form for creating or editing the entity.
  5. Observe that the first entity in the list is already selected.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany marco.b

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

Comments & Activities

  • Issue created by @marco.b
  • 🇵🇱Poland mahyarss

    Thanks for reporting this issue. I can confirm the problem with required entity reference fields auto-selecting the first option when using the Select (ActiveTags) widget.

    I've identified the root cause and prepared a patch that addresses this by:

    • Adding proper empty option handling for required fields
    • Preventing browser auto-selection behavior

    Please test the attached patch and confirm if it resolves the issue for you.

  • 🇩🇪Germany marco.b

    @mahyarsbt

    thanks a lot for providing the patch. I have testet the patch and it works for me.

    What was noticeable during testing was that an entry "– None –" appeared in the Entity Reference form field for half a second, which then immediately disappeared – see screenshot. I just wanted to point this out; it's fine if it's like that.

Production build 0.71.5 2024