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

Comments

Leo Pitt created an issue. See original summary.

leo pitt’s picture

leo pitt’s picture

Status: Active » Needs review
leo pitt’s picture

Updated patch to use setSlotFromRenderArray method.

mostepaniukvm’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good, tested locally and works well. Thanks for contribution!

mostepaniukvm’s picture

Status: Reviewed & tested by the community » Fixed

mostepaniukvm’s picture

Version: 8.x-2.x-dev » 3.x-dev

I just realized that this change is also not backward compatible. I will commit it only to 3.x branch and remove from 2.x

  • mostepaniukvm committed d5d4e478 on 3.x
    Issue #3333344 by Leo Pitt, mostepaniukvm: TextFieldItemProcessor does...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.