Using a translatable string as a category for field type is deprecated

Created on 2 July 2024, 2 months ago
Updated 18 July 2024, about 2 months ago

Problem/Motivation

As per https://www.drupal.org/node/3375748 , usage of translatable string for field type definition category is deprecated.

Steps to reproduce

Check the RelationshipEntityReferenceItem class annotation:

/**
 * Defines the 'group_relationship_target' entity field type.
 *
 * Extends EntityReferenceItem to dynamically support config entities.
 *
 * @FieldType(
 *   id = "group_relationship_target",
 *   label = @Translation("Group relationship target"),
 *   description = @Translation("A reference to either a content or wrapped config entity."),
 *   category = @Translation("Reference"),
 *   default_widget = "entity_reference_autocomplete",
 *   default_formatter = "entity_reference_label",
 *   list_class = "\Drupal\Core\Field\EntityReferenceFieldItemList",
 *   no_ui = TRUE,
 * )
 */

Proposed resolution

Replace the translated category property with:
category = "reference",

Remaining tasks

Fix and commit.

User interface changes

The Relationship Entity Reference field type will appear under Reference category in new field creation UI.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs review

Version

2.2

Component

Code

Created by

🇩🇪Germany Tomefa Dresden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Tomefa
  • 🇩🇪Germany Tomefa Dresden
  • Status changed to Needs review about 2 months ago
  • 🇨🇭Switzerland Berdir Switzerland

    FWIW, defining this on a no_ui field type is pretty pointless, since the category is for the ui, which is disabled here, so the best option might be to just remove it, no concerns about backward compatibility then, but I guess you already require a recent version anyway.

Production build 0.71.5 2024