Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

- [PR-339](https://github.com/OS2Forms/os2forms/pull/339)
Ensure MaestroInheritTask correctly inherits file-elements.

## [5.1.0] 2026-06-03

- [PR-326](https://github.com/OS2Forms/os2forms/pull/326)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\maestro_webform\Plugin\EngineTasks\MaestroWebformTask;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\Plugin\WebformElement\WebformManagedFileBase;
use Drupal\webform\Utility\WebformArrayHelper;

/**
Expand Down Expand Up @@ -160,9 +161,15 @@ public static function webformSubmissionFormAlter(array &$form, FormStateInterfa
// element information to properly set default element values nested
// inside the form.
if ($targetWebform = Webform::load($form['#webform_id'] ?? NULL)) {
$elementManager = \Drupal::service('plugin.manager.webform.element');
foreach ($data as $key => $value) {
if ($targetElement = $targetWebform->getElement($key)) {
if ($element = &NestedArray::getValue($form['elements'], $targetElement['#webform_parents'])) {
// A file element needs its default value as an array.
// @see \Drupal\webform\Plugin\WebformElement\WebformManagedFileBase::setDefaultValue()
if ($elementManager->getElementInstance($element) instanceof WebformManagedFileBase) {
$value = (array) $value;
}
Comment thread
jekuaitk marked this conversation as resolved.
$element['#default_value'] = $value;
}
}
Expand Down
Loading