Problem/Motivation

#1959806: Provide a generic 'entity_autocomplete' Form API element introduced a generic 'entity_autocomplete' Form API element. But it hardcodes a single entity type. While linking, users should (optionally) be able to select which entity type they want to link to.

Proposed resolution

Introduce the equivalent of DER (Dynamic Entity Reference), sans the storage/formatter/widget, only the Form API element.

Remaining tasks

TBD

User interface changes

TBD

API changes

TBD

Comments

dawehner’s picture

As first step we could just make the configuration on the widget settings level.

Dave Reid’s picture

I would also like to select a bundle as well, so I could filter down to only Article nodes, instead of all nodes. Often I've encountered projects that have nodes with the same titles, so this would help with those instances.

webchick’s picture

Agreed that filtering by bundle types is actually probably more important for a lot of use cases than different entity types.

jibran’s picture

jibran’s picture

How about adding a new DER form element to the core which will use ER form element and it'll show a select list with entity type ids? I am doing something similar in above issue with DER widget. We can use dynamic_entity_autocomplete form element instead of entity_autocomplete in link widget.
For #2 we can implement hierarchical select type widget for DER form element in a follow up issue to select bundles.

jibran’s picture

There is a @todo in EntityReferenceAutocompleteWidget::getAutocreateBundle()

        // @todo Expose a proper UI for choosing the bundle for autocreated
        // entities in https://www.drupal.org/node/2412569.

which is kind of similar to #2 but it is only for taxonomies #2412569: Allow setting the auto-create bundle on entity reference fields with multiple target bundles.

amateescu’s picture

Title: Allow an entity type to be selected in the generic 'entity_autocomplete' Form API element » Allow multiple target entity types in the 'entity_autocomplete' Form API element

Opened #2427803: Expose target type, selection handler and selection settings in LinkWidget for #1. I think that was the original intention for this issue but we need two of them anyway, so this can stay open and focused on the 'entity_autocomplete' form element.

Wim Leers’s picture

Version: 8.0.x-dev » 8.1.x-dev

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jibran’s picture

amateescu’s picture

Why not in this issue and by adding support to the current form element?

Edit: oh, I see, that issue is in the DER project, not in core :)

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.