Support more field types

Created on 29 March 2024, about 1 year ago
Updated 4 April 2024, about 1 year ago

Problem/Motivation

Currently the module provides FieldType plugins that act like Text, Date, or Entityreference fields whose values are populated by a token pointing to another such value. We would like to support other field types as well, such as Boolean, number types, etc.

Remaining tasks

Determine which field types to support, and construct Plugins that extend the core types. Computed Field itself supports a few other types of fields, so we can probably use those as a base (similar to what I've done on the existing ones where possible).

User interface changes

Provide more options for Computed Token field types.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada spiderman Halifax, NS

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

Comments & Activities

  • Issue created by @spiderman
  • 🇦🇹Austria maxilein

    Please, add supported field types "Currently the module provides FieldType plugins that act like Text, Date, or Entityreference fields whose values are populated by a token pointing to another such value." to the module page.

    What is not clear to me: does the field accept one token or an expression of tokens?

  • 🇨🇦Canada spiderman Halifax, NS

    @maxilein: the field configuration page for each type has a single "Token value" textfield which accepts a Token (core module). When the Computed Token Field's value is "computed", this module's implementation of the computation essentially *renders* that Token (in the context of building the Node, or whatever entity the field is on), and sets the value of the Text/Date/Reference field with the result.

    If you're asking about handling multiple values, see Handle multi-value fields correctly. Postponed , which is intended to handle the situation where our source (and therefore the computed token field that uses it) produces many values (eg. taxonomy terms).

    I hope that helps- this module is very "hot off the press" if you will, so I'm happy to encounter other uses, and see what it can (and can't) do. If it seems close to your use-case, I'm happy to accept suggestions, questions, and patches/MRs to make it more useful :)

  • 🇦🇹Austria maxilein

    I see. "Computed " sounded more like something generated as a result of an expression... not just the display of a token value.

    So why would I not just use https://www.drupal.org/project/field_token_value ? Why a new module?
    What is the difference?

  • 🇨🇦Canada spiderman Halifax, NS

    @maxilien: I did consider field_token_value as an option, but I was concerned about 2 things. First, we needed to have the "token field" act like a field of the appropriate type (eg. Date, Entityreference) rather than just a text field. Second, I felt that the existing infrastructure in Computed Field was better equipped to handle caching/performance, and ensure the duplicated data (we were effectively "caching" field data from a sub-sub-entity in the node entity it was attached to) stayed in sync. The second one is more rough based on feel looking at the 2 codebases, but the different field types piece was already in Computed Field, so I based this on that. Does that clarify?

  • 🇦🇹Austria maxilein

    Yes. Very much. Thanks.
    Maybe you would like to improve the module page by explaining the difference.

  • 🇨🇦Canada spiderman Halifax, NS

    @maxilein: Absolutely, I'll expand on the project page! Thanks for asking good questions to help elaborate what's important to mention :)

Production build 0.71.5 2024