Skip to content

Commit

Permalink
Merge pull request #39 from systopia/FileArrayFactory-allow-default-v…
Browse files Browse the repository at this point in the history
…alue-to-be-array

FileArrayFactory: Allow default value to be array
  • Loading branch information
dontub authored Oct 4, 2024
2 parents b971b80 + bfb941e commit 62fe681
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 62fe681

Please sign in to comment.