Webform submission token for multivalue download field
Domanda
I'm trying to setup a webform that sends links which can be accessed to download a file. It's working with the first file already, but I can't figure out how to create the token for the other files referenced in a multivalue field:
What's working (for one file):
Here is your requested download: <a href="[webform_submission:node:field_gated_download:entity:field_media_file:entity:url]" target="blank">[webform_submission:node:field_gated_download:entity] </a>
I have tried:
[webform_submission:node:field_gated_download:entity:field_media_file:entity:url:0]
[webform_submission:node:field_gated_download:entity:field_media_file:entity:url:und:0]
[webform_submission:node:field_gated_download:0:entity:field_media_file:entity:url]
[webform_submission:node:field_gated_download:und:0:entity:field_media_file:entity:url]
in almost every combination. It's not working.
Can someone lead me in the right direction?
Soluzione
One approach to this issue is to interpret tokens on your own via hook_tokens().
hook_tokens()
is called every time a token is interpreted and gives you an opportunity to determine how that token is interpreted. Even though the token [webform_submission:node:field_gated_download:entity:field_media_file:entity:url]
is already defined, it may be necessary to also implement hook_token_info() or hook_token_info_alter() in order to define additional modifiers to the token.
It's possible that you might discover the exact token syntax that you need by inspecting the arguments passed into hook_token_info_alter()
.
Here are two tutorials that cover using both hook_token_info()
and hook_tokens()
in order to perform custom token processing.