Steps to reproduce

install drupal 10
PHP 8.2.12

TypeError: key(): Argument #1 ($array) must be of type array, null given in key() (line 424 of modules\contrib\entity_browser\src\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget.php).

Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::processEntityBrowser(Array, Object, Array)
call_user_func_array(Array, Array) (Line: 1013)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 1076)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 1076)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 1076)
Drupal\Core\Form\FormBuilder->doBuildForm('question_entity_text_question_add_form', Array, Object) (Line: 579)
Drupal\Core\Form\FormBuilder->processForm('question_entity_text_question_add_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: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
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)

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

jayprakash.kushwah created an issue. See original summary.

abhishek_gupta1’s picture

Assigned: Unassigned » abhishek_gupta1
jayprakash.kushwah’s picture

Issue summary: View changes
abhishek_gupta1’s picture

Assigned: abhishek_gupta1 » Unassigned
Status: Active » Needs review
StatusFileSize
new1.08 KB

fixed the issue and created Patch.

jayprakash.kushwah’s picture

Status: Needs review » Active

entity_browser-3440973.patch patch is working fine.

jayprakash.kushwah’s picture

Status: Active » Reviewed & tested by the community
sharique’s picture

+1 for RTBC.

berdir’s picture

Status: Reviewed & tested by the community » Needs work

This will just silently hide the notice, but the module won't properly work then I think, so needs clearer steps on how to reproduce.

danrod’s picture

I got the same error on a fresh Drupal 11.1.4 install:

1. Added a new image field for the "Article" content type.
2. In the Form Display Manager, I set that field to use the "Entity Field" widget.
3. if I try to add an article (/node/add/article) I get the same error.

I'm using a ddev instance with PHP 8.2 installed.

bassline’s picture

I installed the entity_browser module in Drupal 10.4.5.
After switching to entity_browser in the content type form display management, I got the same error in the content edit screen.
After applying the #4 patch, I am now able to edit content on the content edit screen.

vipin.mittal18’s picture

Status: Needs work » Reviewed & tested by the community

I faced the same issue, but applying the patch resolved it and unblocked me from creating content.

michaellenahan’s picture

StatusFileSize
new221.33 KB

I got this error, because no entity browser was selected for the field.

Make sure your entity browser instance is set up correctly:

admin/config/content/entity_browser

... then add the entity browser instance to your field

See screenshot:
https://www.drupal.org/files/issues/2025-05-23/2025-05-23-08.59.28-34409...

admin/structure/types/manage/page/form-display
No entity browser selected

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

neclimdul’s picture

Ran into this as well. Reviewing the merge request, the two if statements are just approximating an empty check so simplified it.

Here are the steps I used to recreate this.

1. Create a media field on a node or paragraph if you don't have one to test. It doesn't seem to matter where it exists.
2. On the "Manage form display" tab select "autocomplete" for the widget and save.
3. Now set it back to entity browser and save without expanding the gear and setting up the field.

Without the patch, at this point two things are broken throwing both an undefined array key warning and a fatal type error.
1. From the manage fields tab editing the field is broken.
2. The node form or paragraph addition form seem to also be broken.

With the patch everything is fine
1. Manage fields is normal. I don't see any use widget language so this call might not be strictly necessary.
2. The form "works" but the user is presented with "Entity browser not found. You can select one media item." which would prompt a developer to fix the form display.

jannakha’s picture

Version: 8.x-2.10 » 8.x-2.x-dev
anybody’s picture

Confirming RTBC and the steps in #15. Should be merged.

anybody’s picture

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

dan_metille’s picture

Ok, thanks. I guess that patch can now be removed from schemadotorg module.