Referencing new entity fails when reference method is view or entity is unpublished

Created on 22 June 2016, over 8 years ago
Updated 31 January 2023, almost 2 years ago

On current dev branch referencing new entity fails when entity is unpublished by default.

Steps to reproduce on simplytest.me:

  1. Create a project with inline_entity_form (8.x-1.0-alpha6) and English standard profile.
  2. Enable module inline entity form.
  3. Add new content type Foo and unset default option published in publishing options.
  4. Add field Foo reference of type content reference (Allowed number of values: unlimited) to node type Article.
  5. For Foo reference choose Reference method Default and Content types Foo.
  6. In form display settings choose inline entity form - Complex and allow users to add new nodes.
  7. Add new user John with permission to create Article and Foo.
  8. Login as John and add new Article including new referenced Foo.

The new Foo is created but not the Article. It fails with message "This entity (node: %label) cannot be referenced.".

This error does NOT occure when:

  1. publishing options for Foo is set to published.
  2. You are logged in as admin.

AND it also fails with the same message when choosing reference method Views: Filter by an entity reference view, no matter what publishing options for Foo is set.

Steps to reproduce on simplytest.me like above but:

  1. Add a content view named Foo Entity Reference of type Foo
  2. Add Entitiy Reference to the view and remove Filter criteria Content: Publishing status (= Yes) from it.
  3. Set default option published in publishing options for content type Foo.
  4. For Foo reference field of Article choose Reference method Views: Filter by an entity reference view and your newly added entity reference view.

In this case the referenced entity validation seems to fail because the selection handler is not an instance of SelectionWithAutocreateInterface (see ValidReferenceConstraintValidator line 100: "If the selection handler does not support referencing newly created entities, all of them should be invalidated.").

🐛 Bug report
Status

Needs work

Component

Code

Created by

🇩🇪Germany pminf Nuremburg (Germany), formerly Dresden

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

    Involves, uses, or integrates with views. In Drupal 8 core, use the “VDC” tag instead.

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.

Production build 0.71.5 2024