Entity reference autocomplete's "Add another item" button doesn't work with PostgreSQL

Created on 30 June 2014, over 10 years ago
Updated 19 January 2023, almost 2 years ago

Problem/Motivation

There is a bug in "add another" button inside the entity reference field when using the PostgreSQL database. The bug consists on a sql error inside the ajax requisition, as shown on the attached image, saying that '' isn't a valid integer. This error doesn't happens when using a MySQL database.

Proposed resolution

After some bug tracking, I've found that the root of the problem is that, inside the entityreference_field_widget_form function, there is an entity_load call sending an empty string as an entity_id. The clean solution is if the id is empty inside a previous foreach lace on the code. After this simple change the problem is solved.

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

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

    Particularly affects sites running on the PostgreSQL database.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

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.

No activities found.

Production build 0.71.5 2024