Field templating and multiple value fields not functioning as expected

Created on 25 March 2020, over 4 years ago
Updated 7 June 2023, about 1 year ago

Problem/Motivation

There are a couple of issues caused by the same bug:

  • Fields of type Social Media Links Field don't render through a field template. As a result, the variables also can't be altered with hook_preprocess_field(). The expectation would be that, like any other field, the resulting markup is rendered within a field template and hook_preprocess_field() can be used.
  • Multiple or unlimited value fields (at least when using the "List with all available platforms" widget) only render the last value / highest delta. The expectation would be that every value would render.

Proposed resolution

I traced the issue to the SocialMediaLinksFieldDefaultFormatter class's viewElements() method, which is currently returning a render array. Typically a field formatter's viewElements() method returns an array of render arrays (one item for each delta). Fixing this addresses both issues described above. Field templates and preprocessing become available and every field value renders. I'll be commenting with a patch that accomplishes this.

Remaining tasks

Reviewing the patch that I'll soon attach.

πŸ› Bug report
Status

RTBC

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States guschilds

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