Please also consider those that participated in #2714089: Views Filter by an entity reference view not working as expected when assigning issue credit. Done, see #84.
Problem/Motivation
When an entity relation field displays options via a view the view fields are not used, instead it is the entity label. This is a regression from Drupal 7.x.
Proposed resolution
Update \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::getReferenceableEntities()
to return the Views result rather than just the entity label.
Remaining tasks
None.
User interface changes
None.
API changes
In order continue injecting dependencies, \Drupal\views\Plugin\EntityReferenceSelection\ViewsSelection::__construct()
will add a $renderer
parameter. However, as per the BC changes documentation, this is allowed in minor version releases.
Data model changes
None.
Original report:
I'd like to prepend the content type to the referenceable item titles in the field autocomplete. An entity reference view rewrites the title field as [type]: [title
], and is selected as the "view used to select the entities".
This does not appear to work - the view is used to assemble the list (tested by adding a view filter), but the autocomplete continues to display the item titles only.
This is a regression from entityreference 7.x-1.x