Open Dodger77 opened 1 month ago
In https://github.com/sulu/SuluFormBundle/blob/12d2df14f2af7ea2ec3e0c3cf1f1638c71325b20/Form/Handler.php#L257 there is a bug, that prevents the use of an own upload/attachment field type without the multiple option, so it is necessary to prevent multiple file uploads (e.g. by use of JavaScript).
The part
if (!\count($formField->getData())) { continue; }
leads to the error:
count(): Argument #1 ($value) must be of type Countable|array, Symfony\Component\HttpFoundation\File\UploadedFile given
I think the intention of the code a few lines later
if (!\is_array($files)) { $files = [$files]; }
is to generate an array containing a single UploadedFile object. But that cannot be achieved because of the count before.
UploadedFile
count
Using a custom file upload field type (by overwriting the AttachmentType throughservice decoration or compiler pass) without the multiple option.
multiple
if (!$formField->getData() instanceof UploadedFile && !\count($formField->getData())) { continue; }
Actual Behavior
In https://github.com/sulu/SuluFormBundle/blob/12d2df14f2af7ea2ec3e0c3cf1f1638c71325b20/Form/Handler.php#L257 there is a bug, that prevents the use of an own upload/attachment field type without the multiple option, so it is necessary to prevent multiple file uploads (e.g. by use of JavaScript).
The part
leads to the error:
Expected Behavior
I think the intention of the code a few lines later
is to generate an array containing a single
UploadedFile
object. But that cannot be achieved because of thecount
before.Steps to Reproduce
Using a custom file upload field type (by overwriting the AttachmentType throughservice decoration or compiler pass) without the
multiple
option.Possible Solutions