Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Fixed "Empty validation message for file input when sent array for file input #184" #185

Merged
merged 8 commits into from
Aug 28, 2019
Merged
Prev Previous commit
Next Next commit
Create empty file structure if sent array for FileInput type
  • Loading branch information
ruzann authored Jul 15, 2019
commit fabdf023979b14e53b0b3f31a884524eaee07805
9 changes: 9 additions & 0 deletions src/FileInput/HttpServerFileInputDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ public function isValid($context = null)
'type' => '',
'error' => UPLOAD_ERR_NO_FILE,
];
} elseif(!isset($rawValue['tmp_name']) || !isset($rawValue[0]['tmp_name'])) {
// This can happen when sent not file and just array
$rawValue = [
'tmp_name' => '',
'name' => '',
'size' => 0,
'type' => '',
'error' => UPLOAD_ERR_NO_FILE,
];
}

if (is_array($rawValue) && isset($rawValue['tmp_name'])) {
Expand Down