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.