I have a multi-value image field (Food images) limited to "8" images on the user entity.

The token tree is showing only the 3 tokens for the 3 images as below:

Food images	                        Entity reference field.
Food images type with delta 0	[current-user:field_user_food_images:0:target_id]
Food images type with delta 1	[current-user:field_user_food_images:1:target_id]
Food images type with delta 2	[current-user:field_user_food_images:2:target_id]

But I was expecting to see something like below:

Food images	                        Entity reference field.
Food images type with delta 0	[current-user:field_user_food_images:0:target_id]
Food images type with delta 1	[current-user:field_user_food_images:1:target_id]
Food images type with delta 2	[current-user:field_user_food_images:2:target_id]
Food images type with delta 3	[current-user:field_user_food_images:3:target_id]
Food images type with delta 4	[current-user:field_user_food_images:4:target_id]
Food images type with delta 5	[current-user:field_user_food_images:5:target_id]
Food images type with delta 6	[current-user:field_user_food_images:6:target_id]
Food images type with delta 7	[current-user:field_user_food_images:7:target_id]

Because when I use the token [current-user:field_user_food_images:3:target_id], it return an error: Token not valid

any help about what is going on here ?

Thank you,

Issue fork token-3037538

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

C.E.A created an issue. See original summary.

c.e.a’s picture

Issue summary: View changes
ashrafomar’s picture

There is a hard-coded limit number (3) for all unlimited and limited multi-value field, so I only applied 3 for unlimited and set the limited but multi-value field value to use whatever values is set

ressa’s picture

The problem is that only a single value from a multivalue field is being output, like from a taxonomy term Tag field.

How can you output all values?

sriram s made their first commit to this issue’s fork.

sriram s’s picture

Status: Active » Needs review

Hey, thanks for the patch back in #3 @ashrafomar — you had the right idea, the hard-coded limit of 3 was exactly the problem. I went ahead and re-rolled it since the code moved from token.tokens.inc into TokenTokenInfoHooks.php at some point and the old patch doesn't apply anymore. Opened a new MR with basically the same fix plus a test.

@ressa saw your comment too — outputting all the values already works fine with the plain [node:field_tags] token, and you can reference any delta directly even if it's not listed in the tree, so that part should be covered already. I kept this MR focused on just the tree listing since that's what the issue was originally about, happy to look at the output side separately if it's still an issue for you.

Let me know if anything needs tweaking!