Field Display Label
Allows defining a separate label for field display that differs from the form label.
field_display_label
Install
composer require 'drupal/field_display_label:^2.0'
composer require 'drupal/field_display_label:8.x-1.3'
Overview
The Field Display Label module provides the ability to configure a different label for fields when viewing content compared to when editing content. This is particularly useful when the field label appropriate for data entry differs from the label that makes sense for content display.
For example, a field might be labeled "Body" in the edit form for clarity during content creation, but display as "Description" or "Article Content" when viewing the published content. This separation allows content editors to work with intuitive form labels while providing site visitors with contextually appropriate display labels.
The module integrates seamlessly with Drupal's field configuration system by adding a "Display label" option to every field's settings page. When a display label is configured, it automatically replaces the default field label during field rendering across all view modes.
Features
- Adds a 'Display label' field to the field configuration form for all configurable fields
- Allows different labels for form editing and content display without template overrides
- Stores display label settings using Drupal's third-party settings system for clean configuration export
- Automatically applies display labels during field preprocessing for all view modes
- Works with any fieldable entity type including content types, taxonomy terms, users, and custom entities
- Leaves the original field label unchanged, preserving the editing experience
Use Cases
Multilingual-friendly field labeling
Use technical or internal field labels for content editing (e.g., 'field_hero_cta_text') while displaying user-friendly labels to visitors (e.g., 'Call to Action'). This separation helps content editors identify fields while providing appropriate labels for end users.
Context-specific field naming
A 'Summary' field might be appropriate for content editors, but 'About This Article' or 'Overview' might be more meaningful for site visitors. Configure different display labels for different content types using the same field.
Simplified theming workflow
Instead of creating custom field templates or using template_preprocess hooks to override field labels, simply configure the display label through the admin UI. This reduces the need for custom theme code.
Consistent editing with varied display
Maintain consistent field labels across content types in the editing interface for content editor training and documentation, while customizing how those labels appear to visitors based on the context of each content type.
Tips
- The display label affects all view modes where the field label is visible. If you need different labels per view mode, consider using custom templates instead.
- Leave the display label empty to use the default field label - this is the recommended approach when no separate display label is needed.
- Display labels support translation through Drupal's configuration translation system when the Configuration Translation module is enabled.
- The original field label remains unchanged and is always used in forms, preserving the content editing experience.
Technical Details
Admin Pages 1
/admin/structure/types/manage/{content_type}/fields/{field_name}
The module adds a 'Display label' field to the existing field configuration form. This allows setting a separate label that will be used when displaying the field on the frontend, while the original label remains for form editing.
Hooks 3
hook_form_field_config_edit_form_alter
Alters the field configuration edit form to add the Display label textfield
hook_preprocess_field
Preprocesses field variables to replace the label with the display label if configured
hook_help
Provides help text for the module on the Help page
Troubleshooting 3
Ensure the field's label display setting is not set to 'Hidden' in the Manage display settings. The display label only appears when the field label is configured to be visible (Above or Inline).
Clear the Drupal cache and ensure the module is properly enabled. The setting appears on the field configuration form, not the Manage display form.
The display label is stored as a third-party setting on the field configuration entity. Re-export the specific field configuration (field.field.*.yml) to include the setting.