Problem/Motivation
When changing Media Entity Reference Field Form Display from Image to Entity Browser, it allows to save the change but it sets entity_browser to null and it breaks content creation.
When you export configuration you can see the setting entity_browser is set to null.
Example from core.entity_form_display.node.page.default.yml:
...
field_card_image:
type: entity_browser_entity_reference
weight: 3
region: content
settings:
entity_browser: null
field_widget_display: label
field_widget_edit: true
field_widget_remove: true
field_widget_replace: false
open: false
field_widget_display_settings: { }
selection_mode: selection_append
third_party_settings: { }
field_description:
type: text_textarea_with_summary
When you try to create content you get this error message:
TypeError: key(): Argument #1 ($array) must be of type array, null given in key() (line 424 of /app/web/modules/contrib/entity_browser/src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php).
If you edit the widget again and change it settings to a different option and them save the display, the configuration is saved correctly. And, now you can create content.
Steps to reproduce
1. Create a Media Entity Reference Field
2. Edit form display and change the widget to Entity Browser
3. Save
Proposed resolution
Ensure the entity_browser settings has a initial value when selecting on form display.