Contrib module classes are overwritten

Created on 15 January 2021, over 3 years ago
Updated 21 April 2023, about 1 year ago

Problem/Motivation

If a contrib module is storing css classes as third party setting (e.g. field_formatter_class), those classes get ignored/overridden by hook_entity_display_build_alter which is used by emprty_fields.

Steps to reproduce

  • Have a contrib or custom module add css classes to an entity field - e.g. use the module field_formatter_class.
  • Add a custom class "col-md-2" in the "Field Formatter Class"
  • Field gets properly displayed and the class "col-md-2" is applied to the correct tag.
  • For the same entity field select "Empty value behavior" - "Non-breaking space".
  • The class "col-md-2" is replaced with "empty-fields empty-fields__nbsp", which can break the layout.

Proposed resolution

Check if any modules define classes in "third_party_settings" of the display component.
If so - add them to the field class attributes ['#attributes']['class'] together with the two classes defined in #2927909: Add css class β†’ .

Remaining tasks

Provide a patch.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria JordiK

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