Multiple entity reference fields

Created on 6 October 2023, 9 months ago
Updated 7 October 2023, 9 months ago

I have a node type with 4 entity reference fields to other node types. This is shown in the first screenshot.

If I assign just one field on the form to use the "Autocomplete (hidden IDs)," all is well.

With multiple forms, I am getting a JS error, and only the first three items in the first field have the IDs removed. This is shown in the second screenshot.

I am using:

Bootstrap 5.3
Drupal 10.1.5
PHP 8.1.12

Am I doing something wrong? It may not be a bug if I missed a step.

I tried turning off aggregation for JS.

Any guidance would be appreciated.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States duckydan

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

Comments & Activities

  • Issue created by @duckydan
  • πŸ‡¬πŸ‡§United Kingdom John Cook

    @duckydan, can you provide a link to the theme that you are using? There’s a few using Bootstrap.

    And can you check if the problem is still there if you use Claro as the administration theme.

    Thanks.

  • πŸ‡ΊπŸ‡ΈUnited States duckydan

    Hi,

    I am using Bootstrap5. https://www.drupal.org/project/bootstrap5 β†’

    The website allows members to do a lot of stuff, not just make nodes. If they do add node content, and a different theme appears, would be a jarring and inconsistent UX, so I’m not using a separate admin theme.

    I’ll set it to Claro in my dev environment and see if it still happens.

  • πŸ‡ΊπŸ‡ΈUnited States duckydan

    @john-cook I tried Claro on Chrome and Safari. Same results. Posted screen shots.

    However, I did notice that it stops at an entity that has a non-alphabetical character (in this case, a question mark). Because of that, Drupal sticks the title in quotation marks. Could that be the condition is fails in?

  • πŸ‡¬πŸ‡§United Kingdom John Cook

    I've managed to replicate the issue in both Claro and Bootstrap.

    This happens when the user has entered a non-existent entity when the field doesn't have the "Create referenced entities if they don't already exist" checked. When the page is re-loaded, the replacement fails which crashes the JS runtime.

  • πŸ‡¬πŸ‡§United Kingdom John Cook

    @duckydan

    I think it's because of the quotes and the comma. I need to do some better regex.

  • πŸ‡ΊπŸ‡ΈUnited States duckydan

    Thanks for checking this out!

    If it helps, all the entities are there, and all four fields have the option of "Create referenced entities if they don't already exist" checked.

  • πŸ‡ΊπŸ‡ΈUnited States duckydan

    When I remove that one reference, save the form, and go back in, it works perfectly.

  • @john-cook opened merge request.
  • Status changed to Needs review 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom John Cook

    @duckydan

    I've created a patch that should fix the issue. Can you give it a try please.

  • πŸ‡ΊπŸ‡ΈUnited States duckydan

    @john-cook It works perfectly! I can reference things with the characters, and after I save and go back in, the entire node displays with no ID numbers.

    Thank you so much! This is really big for me.

    A new user to the site asks, "What are those numbers?" and when I explain about entity IDs, they quickly regret asking! LOL.

  • Status changed to RTBC 9 months ago
  • πŸ‡ΊπŸ‡ΈUnited States duckydan
  • πŸ‡¬πŸ‡§United Kingdom John Cook
  • Status changed to Fixed 9 months ago
  • πŸ‡¬πŸ‡§United Kingdom John Cook
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024