Summary
The WebformInherit-task does not correctly handle inheriting file-elements data.
Reproduce
- Create a Maestro flow with a WebformInherit-task that inherits an earlier submission.
- Add a file element, say
document_file, with a limit of one file to both webforms.
- Open the inherit task and see in the logs that something went wrong.
Warning: foreach() argument must be of type array|object, string given in Drupal\file\Element\ManagedFile::valueCallback()
Cause
MaestroWebformInheritTask::webformSubmissionFormAlter() inherits submission data by setting default values. When a singular file is uploaded the submission data value is a string.
Default value expects an array, c.f. WebformManagedFileBase::setDefaultValue().
Fix
Cast to array when default value is being set on any type of file element.
Test
Same as reproduce but with different result:
- Create a Maestro flow with a WebformInherit-task that inherits an earlier submission.
- Add a file element, say
document_file, with a limit of one file to both webforms.
- Open the inherit task and see that the file is correctly inherited.
Summary
The WebformInherit-task does not correctly handle inheriting file-elements data.
Reproduce
document_file, with a limit of one file to both webforms.Cause
MaestroWebformInheritTask::webformSubmissionFormAlter()inherits submission data by setting default values. When a singular file is uploaded the submission data value is a string.Default value expects an array, c.f.
WebformManagedFileBase::setDefaultValue().Fix
Cast to array when default value is being set on any type of file element.
Test
Same as reproduce but with different result:
document_file, with a limit of one file to both webforms.