Follow up from #2856283: Overridden twig field templates have empty content.

Quoted from a comment there:

Ok, we have the same problem as in #2860490: Invalid argument supplied for foreach() in ds_preprocess_ds_layout() line 366 of ds.module. We committed a fix there which we can remove if when #2861840: Preprocess functions are not merged when a module registers a theme hook for a theme-provided template is committed to core. We'll probably need a similar workaround for the field templates too.

Further more, since we're also using a 'base hook' for the DS field templates, this means suggestions won't work, just like in #2802429: Display layout twig not overridable.. That added an insane workaround which we hopefully can remove if we have a solution in #2862683: 'base hook' key prevents template suggestions from working. Will look if I can come up with the same crazy workaround for field templates.

Part one is done. Now part two: make sure all suggestions work and add some more tests. Suggestions for field templates are a bit different than we do for layouts, so the insane workaround which exists didn't work out of the box. So either

  • we need to alter that work around a bit more to discover the right theme hooks
  • change the suggestions, but that's maybe BC break ?

See also #3295021: Field template suggestion is wrong when global default is overridden , #3175273: Field Template Suggestions Not Getting $variables['settings'] and #3187628: template_preprocess_field breaks DS field layout

Comments

swentel created an issue. See original summary.

swentel’s picture

Issue summary: View changes
swentel’s picture

Title: Field template suggestions » Make field template suggestions work

Better title

swentel’s picture

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

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

Issue summary: View changes
swentel’s picture

Issue summary: View changes
swentel’s picture

Title: Make field template suggestions work » Make field template suggestions and preprocess work
Issue summary: View changes
swentel’s picture

swentel’s picture

Title: Make field template suggestions and preprocess work » Make (default) field template (suggestions) and preprocess work

Retitling

swentel’s picture

Title: Make (default) field template (suggestions) and preprocess work » Make field template suggestions and preprocess work

This is funky stuff, but the default setting is fixed soon in #3295021: Field template suggestion is wrong when global default is overridden.

This leaves the suggestions part which work partially. You mostly loose settings, which is kind of annoying, especially for expert.