Support Entities without Bundles, e.G. User

Created on 7 July 2022, almost 2 years ago
Updated 6 December 2023, 7 months ago

Problem/Motivation

Entities do not have to have bundles. A core example is the "User" entity. This module assumes, every entity has a bundle and passes it as config to the autocomplete field. The leads to a database error, because a empty string is passed as bundle.

Steps to reproduce

Create a new Webform element, try to reference a entity from the User entity. It does not work.

Proposed resolution

Do not pass the bundle settings if there are no bundles.

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany maacl

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.

  • πŸ‡«πŸ‡·France O'Briat Nantes

    I don't know if it's totally related but I use the first part of this MR to link to a block.

    The input part works: now the autocomplete let me choose my block instead of a forever loader (+ the ajax call returning a error 500).

    But on form submit I got the following error:
    "Unable to render elements, please view the below message(s) and the error log.
    Call to undefined method Drupal\block\Entity\Block::hasTranslation()
    There has been error validating the elements. You may need to edit the YAML source to resolve the issue."

    I add this modifcation and it seems to fix the problem.

    #src/Plugin/WebformElement/WebformEntityView.php:185
            $entity_view_language = ($entity instanceof TranslatableInterface && $entity->hasTranslation($current_language)) ? $current_language : $entity->language()->getId();
    

    I'll try to provide a MR later

Production build 0.69.0 2024