- Issue created by @srjosh
- Merge request !19Issue #3477472 by srjosh: FieldItemBase category cannot be translatable β (Open) created by srjosh
- π§πͺBelgium BramDriesen Belgium π§πͺ
I think this actually requires a .yml change like the error indicates rather as a change to the FieldType.
Been digging a bit in how core does this and I see no difference in the definition.
Here is a similar issue for a different contrib module: https://www.drupal.org/project/geolocation/issues/3449270 π AssertionError: "Spatial fields" must be defined in MODULE_NAME.field_type_categories.yml Fixed
- π«π·France lazzyvn paris
Please change it is very urgent on drupal 11
change annotation Plugin/Field/FieldType/TimeRangeType.php* @FieldType( * category= @Translation("General"), * id = "time_range", * label = @Translation("Time Range"), * description = @Translation("Time range field"), * default_widget = "time_range_widget", * default_formatter = "time_range_formatter" * )
to php attributes
#[FieldType( id: "time_range", label: new TranslatableMarkup("Time Range"), description: [ new TranslatableMarkup("Time range field"), ], category: "date_time", default_widget: "time_range_widget", default_formatter: "time_range_formatter", )]
and Plugin/Field/FieldType/TimeType.php
@FieldType( * category= @Translation("General"), * id = "time", * label = @Translation("Time"), * description = @Translation("Time field"), * default_widget = "time_widget", * default_formatter = "time_formatter", * list_class = "\Drupal\time_field\Plugin\Field\FieldType\TimeFieldItemList" * )
to php attributes
#[FieldType( id: "time", label: new TranslatableMarkup("Time"), description: [ new TranslatableMarkup("Time field"), ], category: "date_time", default_widget: "time_widget", default_formatter: "time_formatter", list_class: TimeFieldItemList::class, )]
- Status changed to Needs work
2 months ago 4:50pm 10 December 2024 - ππΊHungary nagy.balint
Thank you!
The patch in #6 solved the error.
It is indeed critical as it breaks the add field UI in Drupal 11.
- π§πͺBelgium BramDriesen Belgium π§πͺ
Needs an issue fork.
Is this backwards compatible? As the current release supports
8.8
9
10
and11
- ππΊHungary nagy.balint
I think only 10.2+ since it uses php attributes.
https://www.drupal.org/docs/drupal-apis/plugin-api/attribute-based-plugins β - π§πͺBelgium BramDriesen Belgium π§πͺ
I guess it's ok to drop 8.8 and 9 support as they are both EOL. Plus a bump to 10.2 is also ok I guess.
The patch in #6 adds `list_class: TimeFieldItemList::class,` which doesn't exists in the current codebase. While it fixes the initial issue it introduces a new bug.
I'm attaching the patch from the merge request that only updates the existing annotations.
Just wanted to mention the change records β for the cause of this issue. It explains a way to add backward compatibility in "BC layer" section, but switching to attributes will break it anyway.