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
Comment #2
swentel CreditAttribution: swentel as a volunteer commentedComment #3
swentel CreditAttribution: swentel as a volunteer commentedBetter title
Comment #4
swentel CreditAttribution: swentel as a volunteer commentedComment #5
swentel CreditAttribution: swentel as a volunteer commentedComment #6
swentel CreditAttribution: swentel as a volunteer commentedComment #7
swentel CreditAttribution: swentel as a volunteer commentedComment #8
swentel CreditAttribution: swentel as a volunteer commentedComment #9
swentel CreditAttribution: swentel as a volunteer commentedComment #10
swentel CreditAttribution: swentel as a volunteer commentedAdding #3198320: Different hyphens on fields after changing field templates - need to think about the label class inline/above classes
Comment #11
swentel CreditAttribution: swentel as a volunteer commentedRetitling
Comment #12
swentel CreditAttribution: swentel as a volunteer commentedThis 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.