Synopsis

This module allows developers to create computed fields via the Drupal Plugin API. It adds a field type named computed_render_array.

The idea behind this was to simplify and unify the way we code. We were inspired by https://www.drupal.org/project/extra_field. Now whether it is blocks, extra fields or computed fields, we can use plugins and less hooks.

Computed fields work a bit like extra fields but they are more flexible because you can still use the native field settings (including formatters).

You can use it to merge several fields as one in the display, or simply render a block, an entity...

For example, you have two link fields that you want to display in the same HTML block. You can create a computed field for that. You can still use your normal fields display if you want, it does not affect the original fields.

Another use case could be to render a block between your content fields. You could also decide to display the block according to another field value.

Requirements

No special requirements.

No specific recommendations, you can use this module as is.

Roadmap

This module is minimally maintained. It will be updated if needed but no further development is planned. It is currently compatible with D9.

Known problems

Layout Builder does not support extra fields or computed fields as a whole. See core issue or the issue in this module for updates, but at the moment it is not possible to use both together.

The core currently have an issue with computed fields (see https://www.drupal.org/project/drupal/issues/2932273). Before this can be fixed on the core level, we released a workaround on this module.

This module does not expose any UI, it is meant to be used as an API only, please check the documentation for more details.

Pledges

We pledge to avoid deprecated elements to ensure a smooth upgrade to Drupal 9.

Credits

Current maintainers:

  • Computed Field : This module provides database storage and a back office interface to create computed fields, with a set of field types.
    Our module only allows developers to create computed fields with the Plugin API like they would create a block for example. There is no database storage or user interface, and any type of field can be extended.

Dependencies

No dependency, this module works with the Drupal core.

Restrictions

No restrictions.

Supporting organizations: 
Sponsored the initial development of the module
Sponsored some bugs fixes and improvements of the module

Project information

Releases