Dynamically alter a FieldGroup label with token or otherwise

Created on 12 January 2025, 9 days ago

Problem/Motivation

We need to be able to alter FieldGroup labels on render (in Displays) on a per-fieldgroup usage basis.

Use case

We use FieldGroups in Paragraphs to provide is with Teacher-only hints and tips within out educational site and we do this via Paragraphs that are only visible to teachers and not to students.

Sometimes these Paragraphs are 'Hints', other time they are 'Recommended homework' etc. so we need to alter the labels accordingly. We have added a field (label_replacement) for this purpose.

It feel to us that if the label could use token-replacement then that would sort everything very nicely because then we could simply reconfigure the FieldGroup to use the token of the associated field.

However, if that is not possible to provide easily as a new feature or it is not considered to be a good idea to try to use tokens for this then could anyone please guide us as the custom code required (a hook_alter of some kind) to help in the meantime as we can't seem to identify the right one to use.

Many thanks

💬 Support request
Status

Active

Version

3.6

Component

Miscellaneous

Created by

🇬🇧United Kingdom SirClickALot Somerset

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

Comments & Activities

Production build 0.71.5 2024