-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
Description
Since Symfony 2.5 it's possible to upload multiple files: #8224. Currently it's not possible to validate via @Assert\All({@Assert\NotBlank})
when no files are selected before submitting.
It looks like the request is generated in a wrong way, for these kind of uploads.
// $_FILES
array(
'post' => array(
'name' => array('image' => array(0 => '',),),
'type' => array('image' => array(0 => '',),),
'tmp_name' => array('image' => array(0 => '',),),
'error' => array('image' => array(0 => 4,),),
'size' => array('image' => array(0 => 0,),),
),
)
// Single file before convertFileInformation
array(
'name' => array('image' => array(0 => '',),),
'type' => array('image' => array(0 => '',),),
'tmp_name' => array('image' => array(0 => '',),),
'error' => array('image' => array(0 => 4,),),
'size' => array('image' => array(0 => 0,),),
)
// Single file after convertFileInformation
array(
'image' => array ( 0 => NULL, ),
)
Instead of creating an empty array of files (in this case images), it has created an array with one item that is null. When validating the images via the All validator with an NotBlank assertion, it throws the InvalidPropertyPathException: Could not parse property path "data.image.[0]". Unexpected token "." at position 10
.
This makes it hard to validate multiple files at once.