Error: Call to undefined method Drupal\entity_browser\Form\EntityBrowserForm::getEntity()

Created on 24 August 2023, 10 months ago
Updated 13 March 2024, 4 months ago

Problem/Motivation

this error shows up when using the entity browser to select an image for an image field

Steps to reproduce

addf an image field to a node, enable rabbit hole, use the entity browser to select an image when creating a new node.

Proposed resolution

use this patch

Remaining tasks

patch is attached

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇺🇸United States hazuzoo

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

Comments & Activities

  • Issue created by @hazuzoo
  • Status changed to Needs review 10 months ago
  • 🇺🇸United States nsciacca Connecticut

    I got a similar error with Views Bulk Operations:

    Error: Call to undefined method Drupal\views_bulk_operations\Form\ConfigureAction::getEntity() in Drupal\rabbit_hole\Plugin\Field\FieldWidget\RabbitHoleDefaultWidget->formElement() (line 168 of modules/contrib/rabbit_hole/src/Plugin/Field/FieldWidget/RabbitHoleDefaultWidget.php).

    Adding the below check to the top of the formElement function works for my instance.

    if (!method_exists($form_state->getFormObject(), 'getEntity')) {
       return;
    }
  • 🇮🇳India ayush.pandey

    Hi, the issue seems to not reproducible. I tried the module version 2.0.0-alpha5 with drupal 10.1 and the node gets saved successfully with the media entity. Please check once, and add complete steps if its still reproducible .

  • 🇫🇷France KarimBou

    Having this issue on production Drupal 9.5.x and rabbit_hole 2.0.0-alpha5
    Creating a new article and trying to open entity browser through a paragraph (popup entity browser show the error)

    The website encountered an unexpected error. Please try again later.
    Error: Call to undefined method Drupal\entity_browser\Form\EntityBrowserForm::getEntity() in Drupal\rabbit_hole\Plugin\Field\FieldWidget\RabbitHoleDefaultWidget->formElement() (line 151 of modules/contrib/rabbit_hole/src/Plugin/Field/FieldWidget/RabbitHoleDefaultWidget.php).
    Drupal\rabbit_hole\Plugin\Field\FieldWidget\RabbitHoleDefaultWidget->formElement(Object, 0, Array, Array, Object) (Line: 353)
    Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 220)
    Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object) (Line: 111)
    Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 183)
    Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 190)
    Drupal\inline_entity_form\Form\EntityInlineForm->entityForm(Array, Object) (Line: 152)
    Drupal\inline_entity_form\Element\InlineEntityForm::processEntityForm(Array, Object, Array)
    call_user_func_array(Array, Array) (Line: 1012)
    Drupal\Core\Form\FormBuilder->doBuildForm('entity_browser_entity_browser_images_form', Array, Object) (Line: 1075)
    Drupal\Core\Form\FormBuilder->doBuildForm('entity_browser_entity_browser_images_form', Array, Object) (Line: 1075)
    Drupal\Core\Form\FormBuilder->doBuildForm('entity_browser_entity_browser_images_form', Array, Object) (Line: 579)
    Drupal\Core\Form\FormBuilder->processForm('entity_browser_entity_browser_images_form', Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
    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: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    
    
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    24 pass
  • 🇫🇷France KarimBou

    To avoid some warnings on $form['#type'] array key, that might not exist i've added an isset to the patch.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update 10 months ago
    24 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    24 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 10 months ago
    24 pass
  • 🇧🇾Belarus alexdoma

    patch #6 now working for me
    i have get code from https://www.drupal.org/project/hide_revision_field module and its helps for me
    drupal 10.1.3

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update 10 months ago
    24 pass
  • 🇪🇸Spain JulianVJ

    Not able to reproduce this issue on Drupal 10.1.9 with RabiitHole 2.0.0-alpha5 and Entity Browser 2.10.
    This seems to be a very special use case or applicable onty to Drupal 9

  • 🇺🇸United States philip_stier Denver, Colorado

    I was also getting this exact same error with Entity Browser. #6 worked for me. Drupal 10.1.7

Production build 0.69.0 2024