Entity reference ViewsSelection doesn't take views relationships into account

Created on 12 July 2016, over 8 years ago
Updated 30 April 2024, 6 months ago

Content types

I have defined the following content types:
- Team
- Player
- Game

Entity refernence fields

Team has an entity reference field field_team_players which is a multivalue entity reference field that is used to select the players of the team. In other words, the team knows its players.

Game has two entity reference fields for the teams A and B of the game, field_game_team_a and field_game_team_b. In other words, the game knows the two teams playing in the game.

The game also has fields for the team lineups i.e. the players of the team that actual play in this specific game. In the sport of curling, there are four players (first, second, third, fourth) in the game. Since the players might switch positions from game to game, we want to store the line up for each game. So the Game has the following entity reference fields for the team lineups:
field_game_team_a_1
field_game_team_a_2
field_game_team_a_3
field_game_team_a_4
field_game_team_b_1
field_game_team_b_2
field_game_team_b_3
field_game_team_b_4

Target

Now, what I'm trying to do is to limit the options of the lineup fields to the players of the selected team. In other words, the available options (players) for field_game_team_a_1 should be the players of the team in field_game_team_a. I'm using Views to provide the list of items that can be referenced.

View to limit the items that can be referenced

For the sake of simplicity and to demonstrating this bug I will provide the ID of the Team as a query parameter in the view.

  • The view has a relationship with administrative title Player nodes, i.e. Content referenced from field_team_players
  • The view has a contextual filter Content ID where I will read the ID of the team from a query parameter "team_a" in this example
  • The view has only one field, Content Title, which is using the relationship. In other words, I'm expecting to see the title of the Player nodes.
  • Summary of the view: the view first has a contextual filter for filtering the team, and it then shows the titles of the referenced players of that team.
  • If I look at this view in Views preview, it works as expected: the player titles are shown. It also works as expected if I create a block view. In my opinion it is safe to conclude that the View is working as expected.
  • See the attached screesnshot for the view preview, it is listing the player titles as expected.

Description of the bug

However, when I go to edit the Game, the drop down list of field_game_team_a_1 does NOT show a list of the players of the team. Instead, it is showing only one item and the title of that item is the title of the Team. See attached screenshot.

My conclusion here is that the Relationship of the field Content Title is not taken into account when Entity Reference is building the list of items that can be selected.

Cheers,
Markus

Edit: added formatting so that it is easier to follow the description.

🐛 Bug report
Status

Closed: works as designed

Version

11.0 🔥

Component
Views 

Last updated about 2 hours ago

Created by

🇫🇮Finland masipila

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 Kristen Pol Santa Cruz, CA, USA

    Thanks for reporting this issue. We rely on issue reports like this one to resolve bugs and improve Drupal core.

    As part of the Bug Smash Initiative, we are triaging issues that are marked "Postponed (maintainer needs more info)". This issue was marked "Postponed (maintainer needs more info)" almost a year ago and there has been no activity since that time.

    Since we need more information to move forward with this issue, I am keeping the status at Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • Status changed to Closed: works as designed 6 months ago
  • 🇦🇺Australia pameeela

    The reported issue of the entity ref view not displaying the title based on the relationship has been resolved, but it's worth noting this still wouldn't work as OP expects.

    The view is querying a list of teams, and using relationships to get the player names, but the query is still for teams. So the entity ref being created would be to the team, not the player. What you would need to do is create a view of players, and filter that by team, in order to get the desired functionality.

Production build 0.71.5 2024