Entity reference field View output is not used for selected entity display

Created on 7 September 2016, over 8 years ago
Updated 27 November 2023, about 1 year ago

Follow-up for #2174633: View output is not used for entityreference options β†’ : This covers the display on the form of already selected items.

When an entity relation field displays options via a view the view fields are not used to display the selected entity, instead the entity label is shown. This is a regression from Drupal 7.x.

Steps to reproduce

  • Create a View with an entity reference display and set it up to display more then one field as an inline field
  • Add an reference field to a content type that uses this entity reference display
  • Add a node and fill out the field -> this will show the selected entity as configured in the View (using the selected inline fields)
  • Save the node
  • Edit the node
  • Look at the selected value for the reference field

Expected value:
The entity is shown as configured in the View and the same way as it was shown when the selection was made

Actual value:
The entity label

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Entity referenceΒ  β†’

Last updated 4 days ago

No maintainer
Created by

πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

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

    Related to the Views in Drupal Core initiative.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡«πŸ‡·France dqd London | N.Y.C | Paris | Hamburg | Berlin

    I see all the points and worries but to get forward with this issue and its main focus and primary scope we should prevent to disperse discussion about corners of likes and dislikes in the solution and should minimize the scope as much as possible.

    It is important for custom entities, for big contrib projects like ECK and paragraphs and any data which do not have mandatory title (label) field (and also for the long term future in core since there are discussions about to change the mandatory title field for nodes too) that we get the option at hand to show other than the title field in the edit form after a reference has been selected. -- And from what I understood this issue would solve it.

    Can somebody who is more into this issue, update the summary and can make some notes about what to do next to get forward so that others can chime in to help? Since this issue is a little bit dated it surely needs updates on the to-do list.

  • πŸ‡«πŸ‡·France dqd London | N.Y.C | Paris | Hamburg | Berlin

    More investigating and maybe "good to know" information: For those who use inline_entity_form for creating new entities in the progress of adding them as references can use ief_table_view_mode to get a custom preview of the reference in the edit form display. This solves the problem of entities which have no "label" (title) field looking like empty entries in the preview. Thanks to @mnico for this contribution and important extension for the IEF workflow.

  • Assigned to GuyPaddock
  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

    Taking on additional rework.

  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

    I reviewed the MR feedback (thank you, @ameymudras). I've ticketed πŸ“Œ Replace \Drupal calls with proper IoC in form elements Active under the #2729597: [meta] Replace \Drupal with injected services where appropriate in core β†’ meta issue. That issue should be appropriately scoped to rework form elements like the Entity Auto-complete text field to use DI. I am moving both \Drupal::service('plugin.manager.entity_reference_selection') calls in the class into a utility method and adding a todo that references #3423053. I believe that to be the most prudent way to avoid bloating the scope of this issue.

    Regarding your feedback, @liquidcms, I agree with what I believe @dqd is saying -- the scope of this issue is to fix what value appears in the autocomplete field when a view is being used to drive selections. The question of whether an ID should be suffixed or not is outside the scope of this issue. The issue you are looking for is πŸ› UX: Hide entity ID in autocomplete widget Needs work and until that issue lands, the implementation in this ticket is consistent with both the way that the ID appears during initial selection with a view as well as autocomplete fields that are not driven by a view.

    As for your other question, @dqd, it seems like you found a solution to your problem with IEF. Regardless, I have cleaned up the issue description to clarify that this issue is specific to autocomplete text fields. Please let me know if that addresses your issue, since IEF is completely separate.

  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

    Linking related issues.

  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

    Just updated the branch for 9.5. My next update will update this for 10.1.x.

  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

    Updated for 10.1.x.

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

    Updated for 11.x. Ready for re-review.

  • Pipeline finished with Success
    about 1 year ago
    Total: 486s
    #101033
  • Status changed to Needs work 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Issue summary appears to be missing a few sections

    Added the missing sections but left TBD on sections for someone more familiar with the issue to speak on.

    Also can we hide some of the MRs to just have the intended for 11.x branch. Can be backported later depending when this lands.

  • πŸ‡ΊπŸ‡ΈUnited States gcalex5

    Re-roll of MR 2761 against 10.3.x

  • πŸ‡­πŸ‡·Croatia devad

    Patch #86 applies cleanly to the D11.1.0 and it works nicely for me.

  • For what it's worth: patch #86 also applies cleanly to 10.4.2 and seems to work correctly.

Production build 0.71.5 2024