Entity reference: allow specifiying that every bundle is allowed

Created on 8 February 2019, almost 6 years ago
Updated 1 August 2023, over 1 year ago

Problem/Motivation

In settings of entity reference field, the entity type is marked as required, but the validation allows this to be empty.
A desired feature, as contained in Drupal 7, is when this option are left empty, all bundles are allowed to be referenced.

Steps to reproduce

  1. On a new drupal installation, add a new field(admin/structure/types/manage/article/fields) to the Article content type
  2. On Add a new field select Reference > Content
  3. Choose any name for the field label
  4. On the next screen just click on Save field settings
  5. A new form screen will open and on the Reference Type fieldset you'll see a Content type required field

Proposed resolution

Make the entity type requirement as FALSE and add a short description to notice the users about de behavior when this setting is leave as empty.

Feature request
Status

Needs work

Version

11.0 🔥

Component
Entity 

Last updated about 1 hour ago

Created by

Live updates comments and jobs are added and updated live.
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.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    Seems like a great feature.

    #7 still applies to 10.1 too!

    Was previously tagged for tests which still need to happen

    Thanks!

  • 🇧🇷Brazil murilohp

    I was taking a look at the bug and I've written a new test for it, the test will try to save a new reference field without checking any bundles and then validate the new description. I think this will cover the feature.

    PS: I've also updated the IS with some steps to reproduce.

  • Status changed to Needs review almost 2 years ago
  • 🇺🇸United States smustgrave

    Lets see to review and see what happens!

  • Status changed to RTBC almost 2 years ago
  • 🇺🇸United States smustgrave

    Great job on the tests!

  • Status changed to Needs review almost 2 years ago
  • 🇷🇴Romania amateescu

    The target bundles selector was made required based on UX review of the Entity Reference, very soon after it went into 8.x core, see #1953444: Make 'target bundles' required on the Entity reference instance settings form and #1847596-119: Remove Taxonomy term reference field in favor of Entity reference .

    We shouldn't undo that change without going through a discussion with the usability team.

  • 🇫🇮Finland simohell

    What happens if we have content types
    - Dog
    - Horse
    - Kennel
    - Stable

    In Kennel we have field referencing Dog and in Stable we reference Horses.

    Content type Dog is deleted.

    Will Kennel start referencing Horses as no content type is selected?

    We add content type Fence material.

    Will Kennel then reference Horses and Fence materials?

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States benjifisher Boston area

    Usability review

    We discussed this issue at 📌 Drupal Usability Meeting 2023-02-17 Fixed . That issue has a link to a recording of the meeting.

    For the record, the attendees at the usability meeting were @AaronMcHale, @BlackBamboo, @benjifisher, @gaurav mahlawat, @lauriii, @rkoller, @shaal, and @simohell.

    The points raised in #16 and #17 are valid. We agreed not to follow this approach.

    An alternative to consider is adding an explicit option to toggle between "allow only the selected types" and "allow any but the selected types". This would be similar to the way page restrictions work when configuring block visibility. The other block visibility options do not follow this pattern, but perhaps they should. (See Add support for negating user role condition for block visibility Needs work , for example. I am adding that as a related issue.)

    Another alternative would be to add an "All" option at the top of the list. If that is selected, then hide the other options.

    Before implementing either alternative, it would help a lot to do some user testing and consider other places in Drupal core that folllow similar patterns.

  • 🇬🇧United Kingdom jonathanshaw Stroud, UK
Production build 0.71.5 2024