Tokens don't work for me on Drupal 8 (8.2 rc1), although I do get a "browse available tokens" link and see the tokens in the popup:
admin view of field

The form itself just displays the token machine name rather than the actual value:
frontend view of field

And after I save, it does not get replaced. It just displays the token itself on the page or form.

I was running into this issue on a couple D8 sites where I had Token installed, but to be really sure I wasn't having weird site-specific issues I have been testing this on a clean Drupal 8.2 rc2 installation with no extra modules installed except Token. I have tried some basic tokens like [site:mail] and [current-date:long], and none of them get replaced. I have run db updates (none pending), done 'drush cr' numerous times, and checked the logs for errors (none).

I have tested this on a Basic Page text field (with tokens set as the default value), and have tested it on text field default values on contact forms. I must be missing something really obvious. I did check https://www.drupal.org/node/2578451 but I figured since there's now a beta, at least the most basic tokens ought to be working now.

Comments

caspervoogt created an issue. See original summary.

caspervoogt’s picture

Issue summary: View changes
caspervoogt’s picture

Title: Core Contact forms token support » D8 tokens not getting replaced at all
Issue summary: View changes

changed the title because the issue I am facing is a more general Token one, not related to contact forms specifically.

caspervoogt’s picture

I have been looking for similar issues in the queues, and apparently field default values don't work with tokens yet; see https://www.drupal.org/node/1070878 and https://www.drupal.org/node/2660948.

However, for me, tokens do not get replaced in fields at all, whether it's as a default value or whether I enter the token myself in the field while editing the form, and then saving. I installed Token Filter (https://www.drupal.org/node/2207363) thinking that surely that would solve this for me.. but that does not seem to be working either. I should probably close this issue, but wanted to leave it open a little while to see if anyone can shed light on any of this, just for future people who might stumble across this. It's been hard to tell what I can expect to be working at this time token-wise, and what is still in flux, and it would be nice to document this for others.

berdir’s picture

Category: Bug report » Support request
Status: Active » Fixed

Default value doesn't support tokens nor do tokens in field values. You can't enter tokens anywhere, only in specifically supported elements, which then usually come with a token browser and description about tokens.

You could open a feature request to support it in default values. Token filter might work if it is a text field format and you configure that format to use this filter, but your screenshot looks like a simple text, where it will not work.

caspervoogt’s picture

Berdir, thank you. Obviously, it was not obvious to me that tokens would not work just anywhere. I did end up switching my fields to a field that supports filters, and that worked great.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.