Incompatible with DsFields

Created on 5 June 2018, over 6 years ago
Updated 3 November 2023, about 1 year ago

There is an issue when using moderation_note with Display Suite DsFields.

> Error: Call to a member function getFieldDefinition() on array in moderation_note_preprocess_field() (line 147 of moderation_note/moderation_note.module).

Because Dsfields use the 'field' theme, the element structure is a little funky. moderation_note_preprocess_field expects $element['#items'] to exist, and to be an instance of \Drupal\Core\Field\FieldItemList. However DsField provides an array for this key:

ds/ds.module:389 (ds_entity_view_alter()):

 '#items' => [(object) ['_attributes' => []]],

The only usage in moderation note for getFieldDefinition() is to eventually get the field type. However the preprocess $variables already provides a simpler and consistent way to get it.

The patch removes the use of $element['#items'] to get field type and uses the field type in $variables instead.

Steps to repro bug

  1. Install display suite + moderationnote
  2. Configure with appropriate defaults for an entity
  3. Create a custom DsField. Ensure DsField outputs any value.
  4. Attach to an entity.
  5. View entity.
  6. Error is thrown
πŸ’¬ Support request
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

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.71.5 2024