Error when translatable entities are used

Created on 7 February 2024, 11 months ago
Updated 10 September 2024, 4 months ago

Problem/Motivation

When listing translatable entities in a view, this could happen under Drupal 10.1:

The website encountered an unexpected error. Try again later.

Error: Call to undefined method Drupal\views_entity_form_field\Plugin\views\field\EntityFormField::getEntityRepository() in Drupal\views_entity_form_field\Plugin\views\field\EntityFormField->getEntityTranslationByRelationship() (line 99 of core/modules/views/src/Entity/Render/EntityTranslationRenderTrait.php).
Drupal\views_entity_form_field\Plugin\views\field\EntityFormField->getEntityTranslation(Object, Object) (Line: 491)
Drupal\views_entity_form_field\Plugin\views\field\EntityFormField->viewsForm(Array, Object) (Line: 111)
Drupal\views\Form\ViewsFormMainForm->buildForm(Array, Object, Object, Array) (Line: 172)
Drupal\views\Form\ViewsForm->buildForm(Array, Object, Object, Array)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('views_form_stock_page_1', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 224)
Drupal\Core\Form\FormBuilder->getForm(Object, Object, Array) (Line: 2262)
Drupal\views\Plugin\views\display\DisplayPluginBase->elementPreRender(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 858)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 421)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 493)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 240)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 239)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia kaszarobert

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

Comments & Activities

  • Issue created by @kaszarobert
  • Status changed to Needs review 11 months ago
  • πŸ‡ΈπŸ‡°Slovakia kaszarobert

    Here's a patch for the fix. You need to clear cache after it is applied.

  • πŸ‡ΊπŸ‡ΈUnited States kwiseman

    We've been experiencing the same issue with Drupal 10.3.2 and 10.3.3. The patch is working.

  • Status changed to RTBC 4 months ago
  • πŸ‡«πŸ‡·France Fabsgugu

    Hello,

    I see an error in the EntityFormField class
    Method (getEntityRepository) with same name already defined in this class

    Can you test with the dev version and tell me if that solves the problem? Otherwise you will have to update the patch so that it can work with the dev version.

Production build 0.71.5 2024