Problem/Motivation

Enabling the LottieFiles Field module causes a temporary unavailable error while creating a new field on any content type through UI admin/structure/types/manage/project/fields/add-field.

TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 45 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

This error seems highly related to the discussion in this issue: https://www.drupal.org/project/drupal/issues/3475505

Steps to reproduce

1. Install Drupal 11.1.5 through composer
2. Try to create a new field on any content type

Proposed resolution

API has been changed for new field type categories based on documentation
https://www.drupal.org/node/3375748

Remaining tasks

Full Stack trace
TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 45 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 136)
Drupal\field_ui\Form\FieldStorageAddForm->processFieldDefinitions() (Line: 80)
Drupal\field_ui\Form\FieldStorageAddForm->buildForm()
call_user_func_array() (Line: 528)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 279)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

User interface changes

API changes

https://www.drupal.org/node/3375748

Data model changes

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

sridhar52 created an issue.

pan-pixel’s picture

I was able to reproduce the issue on Drupal 11.2.2. The error is caused by the @Translation(...) in the @FieldType annotation (label, description, category). I applied a temporary workaround that resolved it:

Edit the file:
/modules/contrib/lottiefiles_field/src/Plugin/Field/FieldType/LottiefilesFieldItem.php

Replace this:

  label = @Translation("Lottiefiles Field"),
  description = @Translation("Providing lottiefiles field."),
  category = @Translation("Reference"),

With this:

  label = "Lottiefiles Field",
  description = "Providing lottiefiles field.",
  category = "Reference",

Then run drush cr. Field creation works again without any errors.

iancawthorne’s picture

heilop’s picture

As @iancawthorne mentioned, I think we can close it as a duplicate. I tested the merged MR and worked as expected and the error was gone.