TextFieldItemProcessor does not respect the field's display configuration

Created on 13 January 2023, over 1 year ago
Updated 30 January 2023, over 1 year ago

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

  1. Create a content type with a text field on it.
  2. Configure the content type view mode so that the text field is set up to only output summary text.
  3. Create some content using this content type and provide summary text and different full body text.
  4. 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

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom Leo Pitt

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024