Hi,
I have a form which accepts text and files. After submitting the form, if the validation fails, the previously selected file is not re-selected.
In debug, here is what I receive from the form
// array
'DocumentIDs' => [
(int) 0 => [
'document' => object(Laminas\Diactoros\UploadedFile) id:3 {
private clientFilename => 'Pebble-195x195-1.jpg'
private clientMediaType => 'image/jpeg'
private error => (int) 0
private file => '/tmp/php4uZD8N'
private moved => false
private size => (int) 4434
private stream => null
},
],
],
If it fails at validation, the entity will contain the file (Diactoros
)
// entity
object(App\Model\Entity\Recipient) id:0 {
....
'DocumentIDs' => [
(int) 0 => [
'document' => object(Laminas\Diactoros\UploadedFile) id:66 {
private clientFilename => 'Pebble-195x195-1.jpg'
private clientMediaType => 'image/jpeg'
private error => (int) 0
private file => '/tmp/php4uZD8N'
private moved => false
private size => (int) 4434
private stream => null
},
],
]
}
All the other data in the form populates correctly, except the file. Here is the data returned to the form debug($this)
, which shows the file is empty
// from debug($this). document is empty
protected request => object(Cake\Http\ServerRequest) id:115 {
trustProxy => false
protected params => [ ]
protected data => [
'DocumentIDs' => [
(int) 0 => [
'document' => object(Laminas\Diactoros\UploadedFile) id: 111 {},
],
],
....
How do I insert back the file (Diactoros
) into the form when validation fails ?