Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Computed Token Field

17 sites Security covered
View on drupal.org

This module allows you to create computed fields whose values are automatically populated using tokens. It acts like a regular field but instead of direct input, it uses a token to generate its value, useful for mirroring or combining data from other fields.

Synopsis

This module provides computed fields whose values are calculated based on a token value. The computed field acts like a normal field of the same type (currently supported: Text, Date, and Entity reference fields), but doesn't accept a value directly. Instead, the field instance is configured with a Token which the field renders in order to populate a value for the field. Typical use-cases include "mirroring" fields from other parts of your data model, or concatenating values from multiple fields into a single value.

For example, if you have an embedded Entity/Paragraph attached to a Node, and you need to display a field value from the sub-Entity in a View. Usually a Relationship will suffice here, but sometimes adding lots of Relationships can introduce complexity and duplicate rows in the view. Instead, you can use Computed Token Field to essentially "cache" a copy of the sub-Entity field's value directly on the Node, and then add the computed field to your view without the need for an extra relationship.

This can all be done using Computed Field, but this module allows us to provide simple computed values via a Token without the site builder needing to write a function.

Roadmap

For the moment, the module is feature-complete as required by the project that sponsored it. There are a couple key things that we'd like to see added, but no immediate plans to do so. If you're interested in expanding this module's capacities, patches are welcome!

Known problems

  • Doesn't handle multi-value fields
  • Limited field type support (Text, Date, Entity reference)

Field Token Value is very similar, but provides only a single text field type, so it can't act like a field of a specific type (Date, Entity reference). This means it can't be used as a Filter on a view, for example.

Beyond that, Computed Field is obviously very capable here, providing a lot of facility in terms of cacheability to manage performance, but requires the site-builder to write a PHP function to provide the value. This module instead allows a site-build to provide a simple Token.

Dependencies

Activity

Total releases
1
First release
Mar 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Release date
1.0.0-beta1 Pre-release Mar 12, 2025