Field template suggestion is wrong when global default is overridden

Created on 8 July 2022, over 2 years ago
Updated 29 December 2023, 12 months ago

Problem/Motivation

This is similar to #1885480: theme_hook_suggestions are wrong when specifying "Drupal default" for a field template while Extras uses a different default β†’ .

I have the global default field template set to "Minimal", but if I try to set it to "Default" on an individual field, the template suggestion is still using the "Minimal" option.

Steps to reproduce

  1. Enable twig debugging.
  2. Choose "Minimal" as the default field template.
  3. Go to a display management page that uses a display suite layout and change the field template of a field from the default value of "Minimal" to "Default".
  4. Save and view the entity whose display was modified in the above steps
  5. View the theme suggestions

Proposed resolution

In ds_theme_suggestions_field_alter() there is

    // Determine the field template. In case it's something different.
    if (isset($config['id']) && $config['id'] != 'default') {
      $layout_instance = \Drupal::service('plugin.manager.ds.field.layout')->createInstance($config['id']);

but I wonder if it should be

    // Determine the field template. In case it's something different.
    if (isset($config['id'])) {
      $layout_instance = \Drupal::service('plugin.manager.ds.field.layout')->createInstance($config['id']);

This seems overly simple and my understanding the code is not complete, but it appears to be working for me.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States xenophyle

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