From 9d305bc94a45681e6ef1c38d5c193019e57a5d59 Mon Sep 17 00:00:00 2001 From: Carlos Barberis Date: Mon, 2 Aug 2010 23:13:56 +0000 Subject: [PATCH] BUGFIX: Fixed validation to accept arrays (FileField case) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@108792 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/RequiredFields.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forms/RequiredFields.php b/forms/RequiredFields.php index 3d9b1b7aa..594f514ee 100755 --- a/forms/RequiredFields.php +++ b/forms/RequiredFields.php @@ -100,7 +100,10 @@ JS; if($this->required) { foreach($this->required as $fieldName) { $formField = $fields->dataFieldByName($fieldName); - if($formField && !strlen($data[$fieldName])) { + + // we need to check if $data[$fieldName] is an array (FileFiled case) + if(($formField && $data[$fieldName] == "") || + (is_array($data[$fieldName]) && $data[$fieldName]['name'] == "")) { $errorMessage = sprintf(_t('Form.FIELDISREQUIRED', '%s is required').'.', strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"')); if($msg = $formField->getCustomValidationMessage()) { $errorMessage = $msg;