Problem/Motivation

AssertionError: "Reference" must be defined in MODULE_NAME.field_type_categories.yml in assert() (line 183 of core/lib/Drupal/Core/Field/FieldTypePluginManager.php).

Steps to reproduce

On D11, after enabling the entity_reference_display module and when trying to add a new field on the article content type, I get this error.

Proposed resolution

I have looked up for other issues similar with this one and I found other patches that suggested that the issues might be from the category defined in the EntityReferenceDisplayItem FieldType:

/**
 * Plugin implementation of the 'entity_reference_display' field type.
 *
 * @FieldType(
 *   id = "entity_reference_display",
 *   label = @Translation("Display mode"),
 *   description = @Translation("This field allows you to specify a display mode for entity reference field."),
 *   category = @Translation("Reference"),
 *   default_widget = "options_select",
 *   default_formatter = "list_default"
 * )
 */
#0 /var/www/web/core/lib/Drupal/Core/Field/FieldTypePluginManager.php(183): assert(false, '"Reference" mus...')
#1 /var/www/web/core/modules/field_ui/src/Form/FieldStorageAddForm.php(131): Drupal\Core\Field\FieldTypePluginManager->getGroupedDefinitions(Array, 'label', 'id')
#2 /var/www/web/core/modules/field_ui/src/Form/FieldStorageAddForm.php(80): Drupal\field_ui\Form\FieldStorageAddForm->processFieldDefinitions(Object(Drupal\Core\Form\FormState))
#3 [internal function]: Drupal\field_ui\Form\FieldStorageAddForm->buildForm(Array, Object(Drupal\Core\Form\FormState), 'paragraph', 'carousel')
#4 /var/www/web/core/lib/Drupal/Core/Form/FormBuilder.php(528): call_user_func_array(Array, Array)
#5 /var/www/web/core/lib/Drupal/Core/Form/FormBuilder.php(279): Drupal\Core\Form\FormBuilder->retrieveForm('field_ui_field_...', Object(Drupal\Core\Form\FormState))
#6 /var/www/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\field_ui\Form\FieldStorageAddForm), Object(Drupal\Core\Form\FormState))
#7 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#8 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#9 /var/www/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#11 /var/www/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#12 /var/www/vendor/symfony/http-kernel/HttpKernel.php(183): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /var/www/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /var/www/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /var/www/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /var/www/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /var/www/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#26 {main}

Thank you!

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

vadim.hirbu created an issue. See original summary.

anybody’s picture

Assigned: vadim.hirbu » Unassigned
Priority: Normal » Critical
Status: Active » Reviewed & tested by the community

This breaks Drupal 11 "Add field" functionality entirely. See #3475505: Changes in site building process can run into Cannot access offset of type StringTranslation\TranslatableMarkup on field creation path

This should please be merged asap and a new release needs to be tagged. Thanks!

anybody’s picture

Version: 2.0.2 » 2.0.x-dev
anybody’s picture

Title: Using a translatable string as a category for field type is deprecated » Using a translatable string as a category for field type is deprecated (breaks D11)
grevil’s picture

RTBC, works as expected!

cb’s picture

Can confirm RTBC ✅

Enable module > Go to /admin/structure/types/manage/article/fields/add-field
Error is thrown
Patch module, clear cache, go to /admin/structure/types/manage/article/fields/add-field
Can choose field type

anybody’s picture

@cb could you maybe ping a maintainer?

cb’s picture

@anybody already have 👍🏻

eleonel made their first commit to this issue’s fork.

  • eleonel committed 6cbbcb57 on 2.0.x authored by vadim.hirbu
    Issue #3486365 by vadim.hirbu, anybody, cb, grevil: Using a translatable...
eleonel’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone!

anybody’s picture

@eleonel could you please tag a new stable release for this critical issue? Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

norman.lol’s picture

norman.lol’s picture

norman.lol’s picture

False alarm. It's just you find the view mode field under reference fields and not on the first level as the module page suggests.