Multi-page webform invalid data with image

Created on 4 July 2023, over 1 year ago
Updated 6 August 2023, over 1 year ago

1.0 Problem/Motivation

When having a multi-step form (with or without preview) and on one of the steps/pages we got a contact image field (file upload field), the submitted data do not keep the other changes but just the contact's image.

It looks like that whenever we upload an image for the contact, all the rest of the modifications are gone away/reset to their initial values

2.0 Detailed steps to reproduce (embed screenshots)

* Create a simple webform that has civicrm processing (allow existing contacts to alter their data)
* On the preview setting, set the preview to required, this can become handy for troubleshooting
* Add first/last name, gender, suffix, prefix, contact image url, job title
* Create 2 pages
* On page 1 add first/last name, gender, suffix, prefix while
* On page 2 add job title and contact image url
* Start altering your data, eg gender, prefix, suffix, name etc on Page 1
* Navigate to page 2 and alter the job title and *then* add an image
* Proceed to page 3 (preview), what you should be looking is that your changes are gone and only the contact image is being kept/updated

If you do the same steps but without uploading an image to the contact, your changes are maintained.

3.0 Proposed resolution

Retain the changes with or without an image uploaded

4.0 Hints/Clues on what's going on

On each webform page load, we're reaching this point -> https://git.drupalcode.org/project/webform_civicrm/-/blob/6.2.4/src/Webf...

On each page that we proceed, the array of `$this->form_state->getValues()` is maintaining the whole set of fields

However, when we upload an image on page 2, only the image data are being passed on the `$this->form_state->getValues()` and none of the rest of the data.

Example:

Moving from Page 1 to Page 2, after altering the initial data:

Uploading an image on Page 2:

Page 2 to Preview without image upload:

Below is my test webform structure:

🐛 Bug report
Status

Fixed

Version

6.2

Component

Webform/Drupal

Created by

🇬🇧United Kingdom vangelisp Fife, Scotland

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

Comments & Activities

Production build 0.71.5 2024