Does this module give you tokens for computed fields?

Created on 25 July 2023, 11 months ago
Updated 1 August 2023, 11 months ago

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

πŸ› Bug report
Status

Active

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mariacha1

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

Comments & Activities

  • Issue created by @mariacha1
  • πŸ‡¬πŸ‡§United Kingdom joachim

    Interesting!

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

  • πŸ‡ΊπŸ‡ΈUnited States mariacha1

    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.

  • πŸ‡¬πŸ‡§United Kingdom joachim

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

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Ah.
    field_token_info_alter() is in token module :(

    This is core being crap :(

Production build 0.69.0 2024