When the minimal field template is selected, this template is not applied. Only after saving the widget config, the field template gets used.

Steps to reproduce:

  1. With latest ds-dev
  2. Enable field templates and select the 'Minimal' template (admin/structure/ds/settings)
  3. Apply single collumn layout on article content type
  4. Enable twig debugging (services.yml)
  5. Visit an article node
  6. Check the theme debugging output of any of the article fields.
    Expected: <!-- BEGIN OUTPUT from 'modules/contrib/ds/templates/ds-field-minimal.html.twig' -->
    Actual: <!-- BEGIN OUTPUT from 'core/themes/stable/templates/field/field.html.twig' -->

To get the Minimal field template applied:

  1. At the article display (admin/structure/types/manage/article/display/default)
  2. Edit a field's widget settings
  3. Check that 'Minimal' template is selected and 'Update' without changes.
  4. Save the Article display.
  5. Visit an article node
  6. Check the theme debugging output of any of the article fields. The minimal template is now applied.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sutharsan created an issue. See original summary.

aspilicious’s picture

Issue tags: +Needs tests
protostruct’s picture

FileSize
1.85 KB

Here is a patch that works for me.

Ruslan Piskarov’s picture

Thank you, protostruct.

Your patch works for me.
Attaching the same path with minor fixes.

protostruct’s picture

Hi Ruslan, you are welcome.
I just want to point out that the additions in your patch are entirely unrelated to this issue, mostly formatting related. Why the changes to ds_theme_suggestions_alter? Please put then into separate issues and explain the changes.

aspilicious’s picture

Status: Active » Needs review
protostruct’s picture

When doing it like this, there is no need to store the default field template configuration for every field formatter by default (once touched and saved). But how to properly optimize it?

Setting $default_field_function in ds_field_template_settings_form and ds_field_formatter_settings_summary_alter always to 'default' gives "Field template: default" a different meaning.

To be complete, there should also be the full field template configuration form on the DS settings page.

swentel’s picture

Priority: Normal » Major
Status: Needs review » Needs work

Quick testing revealed that this doesn't seem to work indeed.

When setting it to say 'minimal', the summary in the interface shows 'minimal' which is kind of ok. But you could also expect that it would show something like 'Default (minimal)'. Even setting it to 'Default' doesn't trigger this. So really confusing.

xenophyle’s picture

Wow, this is a pretty major bug. I noticed it because some fields were getting the right CSS and others weren't. I have applied the patch from #3 and initially it seems to work. I don't quite understand the problem reported in #8.

swentel’s picture

Version: 8.x-2.x-dev » 5.0.x-dev
swentel’s picture

Status: Needs work » Closed (cannot reproduce)

Checked again, this seems to be working fine now, probably fixed somewhere else.