Problem/Motivation

I created a computed field "stuff" on my node, and wanted to get that value as a token, like [node:computed_field_stuff] but it doesn't show up in the tokens list at /admin/help/token (or I'm not sure where to look). Does this module create a token for computed fields?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mariacha1 created an issue. See original summary.

joachim’s picture

Interesting!

I wonder whether this is once again because computed fields are defined as code-based bundle fields?

mariacha1’s picture

I bet you're right! Although I then got more complicated and created a base entity type field, but I didn't see it creating any tokens either. Here's what my Plugin docblock looks like:

@ComputedField(
 *   id = "my_test_field",
 *   label = @Translation("My test field"),
 *   field_type = "string",
 *   no_ui = TRUE,
 *   attach = {
 *     "scope" = "base",
 *     "field_name" = "my_test_field",
 *     "entity_types" = {
 *       "taxonomy_term" = {},
 *     },
 *   },
 * )

I ended up defining my own token for this, but was pretty surprised that it didn't seem to work out of the box, so wanted to be sure I wasn't missing something simple.

joachim’s picture

Category: Support request » Bug report

I can't actually see in core where tokens for config fields get defined!

joachim’s picture

Ah.
field_token_info_alter() is in token module :(

This is core being crap :(

joachim’s picture

Title: Does this module give you tokens for computed fields? » Providing tokens for the value of computed fields
joachim’s picture

Title: Providing tokens for the value of computed fields » Add a computed field plugin for a tokenised text field