Entity autocomplete form element ignores entities with label "0"

Created on 24 August 2023, about 1 year ago
Updated 14 February 2024, 9 months ago

Problem/Motivation

It is possible to create an entity with label "0". However, this entity will be ignored by the entity autocomplete form element.

Steps to reproduce

Create a new term with name "0". Take any node type and configure a new field that refers to terms. Set any autocomplete widget for this field. Take any node of this type and open the edit form. Input "0" in the field - there are no autocomplete suggestions. After saving the node, the field will remain empty. However, if you input "0 " (trailing space), then the field value will be saved correctly.

Proposed resolution

Do not use empty() to check the form element value. Do not use the (bool) cast to check the typed string from the URL.

🐛 Bug report
Status

Fixed

Version

10.2

Component
Entity 

Last updated about 11 hours ago

Created by

🇷🇺Russia walkingdexter

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024