mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Better checking of file validity (#6093) Thanks Pigeon (from r113419)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@114533 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
100e50c700
commit
c24ed58d2d
@ -10,7 +10,7 @@
|
||||
* @subpackage validators
|
||||
*/
|
||||
class RequiredFields extends Validator {
|
||||
|
||||
|
||||
protected $required;
|
||||
protected $useLabels = true;
|
||||
|
||||
@ -98,14 +98,19 @@ JS;
|
||||
$valid = ($field->validate($this) && $valid);
|
||||
}
|
||||
if($this->required) {
|
||||
foreach($this->required as $fieldName) {
|
||||
foreach($this->required as $fieldName) {
|
||||
$formField = $fields->dataFieldByName($fieldName);
|
||||
|
||||
$error = true;
|
||||
// submitted data for file upload fields come back as an array
|
||||
$value = isset($data[$fieldName]) ? $data[$fieldName] : null;
|
||||
if(is_array($value)) {
|
||||
$error = ($value) ? false : true;
|
||||
if ($formField instanceof FileField && isset($value['error']) && $value['error']) {
|
||||
$error = true;
|
||||
}
|
||||
else {
|
||||
$error = (count($value)) ? false : true;
|
||||
}
|
||||
} else {
|
||||
// assume a string or integer
|
||||
$error = (strlen($value)) ? false : true;
|
||||
@ -168,4 +173,4 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user