Any hints how to pass the node tokens to multifield subfields?

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

What module are you using that allows you to use node tokens in fields? A better explanation and steps to reproduce would be helpful here.

bkat’s picture

I'm not the OP but I believe I understand what is going on as I'm working through a similar problem.

I have some entity reference fields that I want to use a view to generate the list of acceptable values. In may case, I need to pass the value of another field as an argument to the view so I'm using the patch in https://www.drupal.org/node/2010898 to allow the use of tokens in the entityreference view args.

I have a content type named game with a couple of field that are important here:

  1. field_league - entity reference to the league that the game is part of
  2. field_team -- entity reference to the team(s) playing in the game

For team, I want the select list populated with the teams registered for that league and not all the teams in our system.

If I add field_team directly to the content type, I can use [node:field_league:nid] as the views argument and it works awesome.

If I put field_team inside a multifield (I call it field_teams), then I can't access the parent node. I have access to the subfields of the multifield but now way back to the game node. This is happening because the entity is the multifield pseudo entity and not the parent entity.

In my case, I can work around this. I don't directly create games, instead I have a callback that creates a games for a league and randomly assigns the teams from the teams in the league. So I'm always just editing existing nodes. My team content type, also has an entity reference to the league so I can set the view arg token to [multifield:field-team:field-league:nid]

However, it would be nice to be able to access the game that the multifield belongs to via tokens.

q0rban’s picture

My use case is wanting to use the entity id in a file path. For example, I'm organizing files for a content type using the node id, resulting in files like:

sites/default/files/my-content-type/[node:nid]/hero-image.jpg
sites/default/files/my-content-type/[node:nid]/asset1.pdf
sites/default/files/my-content-type/[node:nid]/asset2.txt
sites/default/files/my-content-type/[node:nid]/asset3.xls
...

It works on all my fields except for the ones inside a multifield, in which case I am presented with an error about the [node:*] tokens being unavailable.