Skip to content

WebformInheritTask does not correctly inherit files #338

Description

@jekuaitk

Summary

The WebformInherit-task does not correctly handle inheriting file-elements data.

Reproduce

  1. Create a Maestro flow with a WebformInherit-task that inherits an earlier submission.
  2. Add a file element, say document_file, with a limit of one file to both webforms.
  3. 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:

  1. Create a Maestro flow with a WebformInherit-task that inherits an earlier submission.
  2. Add a file element, say document_file, with a limit of one file to both webforms.
  3. Open the inherit task and see that the file is correctly inherited.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions