Problem/Motivation

In ckeditor5_entity_browser 3.0.0, clicking "Insert" in the entity browser dialog throws a fatal error and the modal does not close:

Symfony\Component\HttpFoundation\Exception\BadRequestException:
Unexpected value for parameter "entity_browser_select": expecting "array", got "string".
in Symfony\Component\HttpFoundation\ParameterBag->all()
(line 52 of vendor/symfony/http-foundation/ParameterBag.php)

ckeditor5_entity_browser.module uses $request->request->all('entity_browser_select') to read the POST value. In Symfony 7 (shipped with Drupal 11), ParameterBag::all(key) strictly requires the value to be an array — it throws BadRequestException immediately when a scalar string is submitted. The fallback get() call is never reached.

Steps to reproduce

1. Install drupal/ckeditor5_entity_browser 3.0.0 on Drupal 11 (Symfony 7)
2. Open any node edit form with a CKEditor 5 body field
3. Click "Insert Media" in the toolbar
4. Select a media item and click "Insert selected"
5. → BadRequestException is thrown; modal does not close

Proposed resolution

Replace the all() call with get() and normalize the value to an array manually, handling both scalar string and array input:

$raw_selection = $request->request->get('entity_browser_select');
if (is_array($raw_selection)) {
  $selection = $raw_selection;
}
elseif (!empty($raw_selection)) {
  $selection = [$raw_selection];
}
else {
  $selection = [];
}
$selection = array_filter($selection);

This is backward-compatible: array submissions (multi-select widgets) continue to work via the is_array() branch, while scalar string submissions are safely wrapped into an array.

Remaining tasks

- Review and apply the proposed fix
- Add a test case covering both scalar and array values for entity_browser_select

User interface changes

None.

API changes

None.

Data model changes

None.

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

    revathidinesh created an issue. See original summary.

    revathidinesh’s picture

    remco hoeneveld’s picture

    Great stuff i have added this to the latest release 3.0.2

    remco hoeneveld’s picture

    Status: Active » Fixed

    Now that this issue is closed, review the contribution record.

    As a contributor, attribute any organization that helped you, or if you volunteered your own time.

    Maintainers, credit people who helped resolve this issue.

    Status: Fixed » Closed (fixed)

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