Translated label and settings incorrectly saved as original configuration

Created on 8 December 2020, over 4 years ago
Updated 8 April 2025, 16 days ago

Problem/Motivation

On multilingual sites, field group labels (and all other translatable properties) are overriden with the values from the current UI language on form submisson. This causes data loss (the original texts).

Steps to reproduce

  1. Have a multilingual Drupal site, with config_translation and 🐛 Entity view/form mode formatter/widget settings have no translation UI Needs review
    Example: EN (default), DE
  2. Configure a view mode (form mode works alike) in default language (EN) with a field group, specify a label
    Example: /en/admin/structure/types/manage/article/display/full with a "Contact" group
  3. Translate the view display into DE, using the Core UI, including the field group label
    Example: "Kontakt"
  4. Edit the view mode from the DE UI
    Example: /de/admin/structure/types/manage/article/display/full
    • See: Field group is (human) labeled "Kontakt" (expected)
    • Open the field group edit form, see label "Kontakt" (incorrect, expected "Contact")
    • Submit the field group + view mode form
  5. Edit the view mode from the EN UI (= the configuration's default language)
    • See: Field group is (human) labeled "Kontakt" (incorrect, expected "Contact")
    • Open the field group edit form, see label "Kontakt" (incorrect, expected "Contact")

What happened? The display entity was loaded manually, in the language suitable for the UI (= translated). Those values were then used in the form, which saves the settings in the config's original language.
The core patch is only required to provide a UI - we only require a translation override, e.g. from a configuration sync.

Proposed resolution

Depending on the context, use the provided entity (i.e. $form_state->getFormObject()->getEntity() or explicitly load the display entity without translation overrides:

  $storage = \Drupal::entityTypeManager()->getStorage('entity_' . $context . '_display');
  $display = $storage->loadOverrideFree($entity_type . '.' . $bundle . '.' . $mode);

This applies especially to field_group_info_groups, but the display entity is also loaded manually in other functions.

On view/form display forms, the field group human_name needs additional handling to apply translations.

Remaining tasks

Write tests, patch and review.

User interface changes

On view/form display forms, the field group element forms will display texts in the configuration language, regardless of UI language.

API changes

TBD

🐛 Bug report
Status

Active

Version

3.0

Component

Miscellaneous

Created by

🇩🇪Germany ckaotik Berlin

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024