Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When DS field templates are enabled, the field template form renders on Layout Builder FieldBlocks but doesn't work.
Steps to reproduce
- Enable DS Field Templates and the Layout Builder module
- Enable Layout Builder on a Content type and click "Manage Layout"
- Click "+Add Block" on a section and add any field block from the "Content field" section
- Change the field template select - the form won't update with the selected field template settings
Proposed resolution
- Update the ds field template-related form and preprocessors to sniff out when the field is being rendered by Layout Builder and handle accordingly
- Add a setting to disable field templates in layout builder entirely. There are likely cases where you don't need field template support in layout builder but still want it on the Manage Display page.
Patch Incoming!
Comment | File | Size | Author |
---|---|---|---|
#2 | ds--layout_builder_field_templates--3164071-02.patch | 15.31 KB | drclaw |
Comments
Comment #2
drclaw CreditAttribution: drclaw at Fuse Interactive commentedHere's a patch addressing the above!
Comment #3
drclaw CreditAttribution: drclaw at Fuse Interactive commentedNees review
Comment #4
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedThis is pretty cool, will review and test today!
Comment #7
swentel CreditAttribution: swentel at eps & kaas for Dropsolid commentedImpressive! I had no idea field templates were exposed on the field blocks. Further more, they indeed currently trigger an error when changing the field template. So this patches fixes both the error and makes field templates actually work on rendering, even during the preview phase, that's so cool! And it has a test, even better :)
Committed and pushed to 8.x-3.x and 8.x-4.x thanks!
(removed an unused Cache import in the test)
Thanks! Will let it live a week or two in the dev branches so I can test it a bit more on production environments, although I don't expect any issues honestly.
Comment #8
drclaw CreditAttribution: drclaw at Fuse Interactive commentedAwesome! Thanks for the quick review/response!! :)