1.0 Problem/Motivation
You cannot submit a webform that has a existing contact record that is displayed as a select list when you also have a file upload.
2.0 Detailed steps to reproduce (embed screenshots)
1. Create a webform with just one contact that only includes the existing contact field
2. In the Build tab, change the "Form Widget" from "Static" to "Select List". Optionally set a CiviCRM group to limit contacts to avoid a giant list.
3. Add a file upload (it can be either a CiviCRM file upload or a Webform file upload)
4. Fill out the form
If you select a contact but do not upload a file, it works.
If you select a contact AND you upload a file, you get an error: The submitted value 97481 in the Existing Contact element is not allowed.
3.0 Proposed resolution
Still working on it.
However I have identified the problem.
1. WebformCivicrmPreProcess::alterForm returns early when it detects that the user is uploading a file and it does not call $this->fillForm().
2., $this->fillForm() is the function that loads the contact options for the existing contacts. This is not a problem immediately, but the form is cached without the options
3. In, core/lib/Drupal/Core/Form/FormBuilder::buildForm(), if Drupal detects that the form has been cached, it uses the cached version and doesn't rebuild it from scratch.
4. When validation happens, the contact options are not present, so the form fails to validate the chosen existing contact
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screenshot from 2026-04-07 18-47-24.png | 62.92 KB | m_hobby |
| #7 | Screenshot from 2026-04-07 17-27-54.png | 59.83 KB | m_hobby |
Comments
Comment #2
jmcclelland commentedIt seems that CiviCRM Options that are live options do persist in the cache, so I'm still not 100% why existing contact options do not.
Comment #3
karingI've seen this before. We were in a crunch to get a major project onto D10 so we just worked around it by changing the existing contact element widget to Autocomplete (instead of Select). Apologies for not even documenting this...
If you can work on a fix that would be great. I'd be happy to write a test to secure it.
Comment #4
m_hobby commentedCan confirm this bug still exists and can replicate with the steps described.
In case other people find this edge case, it is possible to sidestep the bug and keep the select widget.
Simply add a page break after the existing contact field and place the file upload on the next page.
The field value is properly stored in the form data and can then accept the file upload.
Hope there is a fix for this at some point.
Comment #5
jitendrapurohit commentedI've raised a PR here: https://github.com/colemanw/webform_civicrm/pull/1095
Could anyone please confirm if this fixes the error for you?
Thanks.
Comment #7
m_hobby commentedHi @jitendrapurohit,


I can confirm the issue still exists on 6.3
Applying the patch fixes the issue, I can confirm I was able to upload an image and submit sucesfully.
This is good to close, now 6.3.2 is out.
Comment #8
karingThank you for testing!