Skip to content

Commit

Permalink
FileArrayFactory: Allow default value to be array
Browse files Browse the repository at this point in the history
The default value is an array, if it was fetched from the temporary
values.
  • Loading branch information
Dominic Tubach committed Oct 4, 2024
1 parent 33dc2f0 commit bfb941e
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ public function createFormArray(
] + BasicFormPropertiesFactory::createFieldProperties($definition, $formState),
];

// If the default value was fetched from the temporary values, it should
// be an array. If it was fetched from the field definition, it should be
// an \stdClass.
if (is_array($form['file']['#default_value'] ?? NULL)) {
$form['file']['#default_value'] = (object) $form['file']['#default_value'];
}

if (($form['file']['#default_value'] ?? NULL) instanceof \stdClass
&& is_string($form['file']['#default_value']->url ?? NULL)
&& is_string($form['file']['#default_value']->filename ?? NULL)
Expand Down

0 comments on commit bfb941e

Please sign in to comment.