Trouble saving tokens

Created on 10 July 2025, 1 day ago

Problem/Motivation

I am working on implementing an action plugin over in social post mastodon: https://www.drupal.org/project/social_post_mastodon/issues/3535066 ✨ Integrate with ECA Active

Here is a direct link to the action: https://git.drupalcode.org/issue/social_post_mastodon-3535066/-/blob/353...

This action still needs some work, but this behavior is still unexpected.

My plan is to utilize token replacement for both user id and message configuration fields on my action. Initially, I attempted to add tokens to my field by clicking on the field and then on the token like I normally do elsewhere in Drupal. I first found that the token would not go into the field. I poked around the eca module and found that some of the actions that were designed with tokens in mind have this property on the field:

'#eca_token_replacement' => TRUE,

By adding that, I was able to add tokens to my field by clicking on them. Excellent. But my next issue, was that when I click save, or click out of the task contains my configurable action, and then go back into my task, I see that the token I added to my field is gone.

For a little bit, I thought I was doing something wrong in my action, but I have found that this behavior is not unique to my action. I have noticed that while I cannot add tokens to fields that do not have this property, if i manually type the token into such a field field, then it will save properly.

I would like to have my cake and eat it too.

Steps to reproduce

Add a token to a field with the property mentioned above, click outside of the task (or save and reload the page), and click back into it. See that the token is gone.

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @MegaKeegMan
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan
  • πŸ‡ΊπŸ‡ΈUnited States MegaKeegMan

    Okay was able to resolve my issue. Jurgen informed me that clicking on tokens in the token browser is not supported. My issue was that I am sometimes able to click on tokens in the token browser to populate the field. When that happens, I do see visually that the field does in fact get populated. But when saving the form, Drupal does not know that there is a value there, and so it does not get saved. But the good news is that if I type manually (or copy and paste), it does actually work as expected.

Production build 0.71.5 2024