Problem/Motivation
Opening any "Add field" admin page (e.g. /admin/structure/taxonomy/manage/*/overview/fields/add-field) on Drupal 11 throws a fatal AssertionError and the modal fails to load:
AssertionError: "General" must be defined in MODULE_NAME.field_type_categories.yml in assert() (line 183 of core/lib/Drupal/Core/Field/FieldTypePluginManager.php)
The root cause is in SimpleTimeFieldItem.php, which declares its @FieldType category using a translated label:
category = @Translation("General"),
Since Drupal 11, FieldTypePluginManager::getGroupedDefinitions() groups field types by their category value and validates each group key against registered category plugin IDs from *.field_type_categories.yml files. The plugin ID defined in core.field_type_categories.yml is general (lowercase), but @Translation("General") resolves to the string "General" (capital G) — which does not match any registered plugin ID, triggering the assertion.
Steps to reproduce
- Install Drupal 11 with
simple_time_field1.3.0 enabled. - Navigate to any entity's "Manage fields" page (e.g.
/admin/structure/taxonomy/manage/work_type/overview/fields). - Click "Add field".
- Observe the
AssertionError— the field type selection modal is blank.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | simple_time_field-field_type_category_plugin_id_drupal11-3576503-1.patch | 617 bytes | boychev |
Comments
Comment #2
boychev commentedProposed resolution
Change the category annotation from a translated label to the plugin ID string, consistent with how all Drupal core field types declare their category (e.g.
category = "reference",category = "date_time"):- * category = @Translation("General"), + * category = "general",Comment #3
boychev commentedComment #4
sujan shrestha commentedFixed in 1.4.x and released in 1.4.0:
https://git.drupalcode.org/project/simple_time_field/-/commit/6cc259ff24...
https://www.drupal.org/project/simple_time_field/releases/1.4.0
Your diagnosis was right: the field type declared its category as a translated label, while Drupal 11 expects the category plugin ID. The field type now uses a PHP attribute with category: 'general', as core does. A new functional test opens the "Add field" page, so this is covered from now on.
The same cause also produced the TypeError in #3584027, which is fixed by the same change.
Thanks @boychev for the clear report and the patch.