Reference Table Formatter compatibility

Created on 30 June 2022, almost 3 years ago
Updated 21 April 2023, almost 2 years ago

Problem/Motivation

Empty Fields is incompatible with Reference Table Formatter .

The issue manifests itself in Reference Table Formatter, however, I believe the problem is best resolved in Empty Fields.

Error: Call to a member function getFieldDefinition() on array in Drupal\reference_table_formatter\EntityToTableRenderer->fieldIsRenderableContent() (line 185 of modules/contrib/reference_table_formatter/src/EntityToTableRenderer.php)

I also posted in Reference Table Formatter. https://www.drupal.org/project/reference_table_formatter/issues/3174495

There is also an issue where the fields of the entity referenced-table are not ordered correctly. This appears to be because the weight is not restored in empty_fields. I can't reproduce this issue with any built-in entity reference, such as taxnomies, however I can imagine that other modules may run into a similar issue.

Steps to reproduce

The requires both Reference Table Formatter and Empty Fields. In my case, I am using Reference Table Formatter to render a table of media entities. Empty Tables breaks when rendering a media entity with a field that enables Empty Fields.

Proposed resolution

Set the entity field's items object to the #items build value.

When reviewing EntityViewDisplay::buildMultiple, the items appear to come directly from the $entity->get() through FormatterBase::view(), which returns an object that implements aFieldItemListInterface. Reference Table Formatter counts on this object.

For the weight issue. We just need to restore the weight. It's provided in the component.

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇨🇦Canada bzaher

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