Webform prepopulate on multivalue fields returns BadRequestHttpException: Input value "*FIELD_NAME*" contains a non-scalar value.

Created on 7 September 2023, about 1 year ago
Updated 5 October 2023, about 1 year ago

Problem/Motivation

Trying to prepopulate multiple values through the query params returns an error.

Steps to reproduce

  1. Create a webform with for example an entity_select field and set the field to allow multiple values.
  2. Enable prepopulate by query.
  3. View your webform and try to prepopulate it with an array query param (for example ?test[]=1&test[]=2)

Proposed resolution

Update the prepopulateData() method in WebformSubmissionForm.php (see patch)

πŸ› Bug report
Status

Closed: duplicate

Version

6.2

Component

Code

Created by

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

Comments & Activities

  • Issue created by @danekin
  • Status changed to Needs review about 1 year ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    534 pass
  • Status changed to Postponed: needs info about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    I am not able to replicate this issue using the attached webform.

    Please provide more information on how to reproduce this issue.

    Can you reproduce this issue using https;//simplytest.me?

  • πŸ‡©πŸ‡ͺGermany mspae

    We experienced the same issue. The patch in #2 worked for us.

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

    Patch #2 solve for our us. Was occurring on name and advanced address composite fields.

    URL is something like:
    https://test.site/form?name%5Bfirst%5D=Tester&name%5Blast%5D=Test&address%5Bpostal_code%5D=10000-0000&address%5Bcountry_code%5D=US

  • This is due to a breaking change in Symfony 6 (used by Drupal 10) that no longer allows arrays as the return type of `InputBag::get`. See a similar fix that was made in another area of the Webform module: https://www.drupal.org/project/webform/issues/3335962 πŸ› File input value contains a non-scalar value Fixed

    This is a pretty high priority regression IMO, it will give an error and fail to render the webform on any link that is using prepopulated arrays in the query string.

    @jrockowitz Attached is a repro webform. The difference here is that yours has the global `form_prepopulate` setting enabled, which does not trigger this error, as it follows a different codepath at `WebformSubmissionForm.php:L2651`. Disabling the global setting and enabling prepopulate on the individual form element allows the error to happen.

  • πŸ‡ΊπŸ‡ΈUnited States gregory.clapp Portland, OR

    I'm having the same issue with prepopulating a custom composite field instantiated from a custom module that I created, and the patch resolves it. However, I can't reproduce the issue on a simplytest.me instance using a custom composite I created through the UI. There must be another factor involved.

  • Status changed to Closed: duplicate about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    @see πŸ› Prepopulate fails in Drupal 10 Needs review

    @danekin I will give you commit credit on that ticket.

Production build 0.71.5 2024