There are cases where you want to display tokens that are specific to a context. Much more context than the current token UI api understands.

In webform (see below) we have general webform tokens. They are always valid in the context of a webform.
However there are also tokens that are only valid in the context of a webform submission. Per webform node you have specific components where each component has its own values per submission. Those are all different per webform id.

From what i've seen this is currently not supported by token UI. Meanwhile we have added a meta-key.. but that's no good usability...

+  $info['tokens']['webform-submission']['submission:KEY'] = array(
+    'name' => t('Webform submission component value'),
+    'description' => t('Webform tokens from submitted data. Use the component "Field Key" of the component as KEY.'),
+  );

Could you please tell us how to deal with such things cleanly?

Somewhat of a followup of
#1196354: Add cache clear on field update and field delete
and the webform token integration
#1001798: Rewrite token replacement system to use D7 tokens

Comments

Dave Reid’s picture

Status: Active » Fixed
  $info['tokens']['webform-submission']['value'] = array(
    'name' => t('Webform submission component value'),
    'description' => t('Webform tokens from submitted data. Use the component "Field Key" of the component as KEY.'),
    'dynamic' => TRUE,
  );

I swear I had something like this in the original issue.

miro_dietiker’s picture

Status: Fixed » Active

Thank you dave. We'll fix that.

What we actually would prefer is that token UI also displays all possible tokens based on context information. We might post you a suggestion on how to extend token UI with additional hooks and context information to support this feature request with more usability.

I believe it's very limiting in user experience that people must consult some other page to actually find out what KEYs are supported.

Murz’s picture

subscribe

Murz’s picture

So, this issue is fixed in HEAD or no? Or how I can insert submission values (or submission id) into confirmation message or page text via current webform?
If patch is needed for this, where can I get it?

miro_dietiker’s picture

The referred issue from webform contains a fix:
#1001798: Rewrite token replacement system to use D7 tokens

wizonesolutions’s picture

There's also Webform tokens.

miro_dietiker’s picture

Webform tokens is something completely different.

Webform has now the new token system in place. #1001798: Rewrite token replacement system to use D7 tokens
Thus per webform node we have different tokens - at least one for each form component you add.
We should be able to handle such stuff as tokens in the UI and inject such token definitions based on the current context.
They cannot be covered / cached with the current static Token UI approach.