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:
The form itself just displays the token machine name rather than the actual value:
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.
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2016-09-07 at 9.20.47 PM.png | 19.31 KB | caspervoogt | |
Screen Shot 2016-09-07 at 9.22.03 PM.png | 80.96 KB | caspervoogt |
Comments
Comment #2
caspervoogt CreditAttribution: caspervoogt at Plethora commentedComment #3
caspervoogt CreditAttribution: caspervoogt at Plethora commentedchanged the title because the issue I am facing is a more general Token one, not related to contact forms specifically.
Comment #4
caspervoogt CreditAttribution: caspervoogt at Plethora commentedI 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.
Comment #5
BerdirDefault 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.
Comment #6
caspervoogt CreditAttribution: caspervoogt at Plethora commentedBerdir, 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.