I want to use Webform 8.x-5.x in Drupal 8 to create a personal contact form to be used by logged in users to send personal messages to each other.
At the same time I am using the Profile module to store other information for these users, including a Display Name for them.
Now, on the personal contact form I'd like to show the Display Name of the logged-in user in a "From" text field, and the Display Name of the recipient user in a "To" text field.
I know how to display a token as a default value in a text field. However the Token UI shows the global and Webform tokens only.
I also know that I can make my own module and use hook_token_info()
and hook_tokens()
to get the Display Name into a token.
But once I have my tokens with the desired information, how do I then get them to show up in the Webform Token UI so that I can use them as default values for my text fields on the form?
To be more precise, the question is, how do I get non-global and non-Webform tokens to show up in the Webform Token UI so that I can use them in Webform?
hook_token_info()
andhook_tokens()
. As @4k4 mentioned, my custom tokens just show up and I can use them.