Display selected existing text fields using labels embedded in their values. Drupal 11 ready
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
astanley 90a0de695c initial commit 11 hours ago
config initial commit 11 hours ago
src initial commit 11 hours ago
templates initial commit 11 hours ago
tests/src/Unit initial commit 11 hours ago
README.md initial commit 11 hours ago
composer.json initial commit 11 hours ago
dynamic_field_label.info.yml initial commit 11 hours ago
dynamic_field_label.links.menu.yml initial commit 11 hours ago
dynamic_field_label.module initial commit 11 hours ago
dynamic_field_label.permissions.yml initial commit 11 hours ago
dynamic_field_label.routing.yml initial commit 11 hours ago

README.md

Dynamic Field Label

Drupal 10/11 custom module for existing configurable text fields. No field type, field schema, import or stored data changes are required.

Installation

Place this directory in web/modules/custom/dynamic_field_label (or the custom module directory appropriate to your project), then run:

drush en dynamic_field_label -y
drush cr

Go to /admin/config/content/dynamic-field-label and select the fields. field_custom is selected by default. The configuration matches machine names across all entity types and bundles. The permission is administer dynamic field labels.

Rendering

Publisher:University of Prince Edward Island displays as a Publisher label and University of Prince Edward Island value. Only the first colon is a separator. Whitespace around both parts is trimmed. An empty value is permitted; an empty label or missing colon falls back to the existing formatter output. Multiple values each receive their own label. Embedded labels are shown even if the Drupal label is hidden. Labels are escaped plain text and must not contain HTML tags. Values from formatted text fields are rendered through Drupal’s processed_text render element using the stored text format; plain string fields and entries without a format remain escaped plain text. Use input such as Publisher:<strong>UPEI</strong>. Do not wrap the label or entire input in HTML (for example <p>Publisher:UPEI</p>); such input falls back to the original formatter. Parsed entries display the full value rather than a trimmed formatter or summary. Invalid entries preserve formatter output; in a mixed field the original label is repeated for invalid entries unless hidden. The module provides a field template using standard field CSS classes; a theme can override field--dynamic-field-label.html.twig.