Problem/Motivation
Text fields output through custom_elements do not inherit the field display settings that have been configured on their parent entity.
For example, we have an article content type. There is a body field on the article. The article teaser display mode is configured such that the body field should only show the "Summary or trimmed" content. But the created element always contains both the full body, and the summary text if it has been provided.
Steps to reproduce
- Create a content type with a text field on it.
- Configure the content type view mode so that the text field is set up to only output summary text.
- Create some content using this content type and provide summary text and different full body text.
- Review the custom_elements output for this content. It should provide just the summary text (as configured), but instead outputs the full text.
Proposed resolution
Alter `TextFieldItemProcessor` and use `FieldItemInterface::view`, passing the view mode, to generate the field render array.
Remaining tasks
Review and merge the patch.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | textfielditemprocessor-does-not-respect-fields-display-configuration-3333344-4.patch | 748 bytes | leo pitt |
Comments
Comment #2
leo pitt commentedPatch attached.
Comment #3
leo pitt commentedComment #4
leo pitt commentedUpdated patch to use setSlotFromRenderArray method.
Comment #5
mostepaniukvmPatch looks good, tested locally and works well. Thanks for contribution!
Comment #7
mostepaniukvmComment #9
mostepaniukvmI just realized that this change is also not backward compatible. I will commit it only to 3.x branch and remove from 2.x