From f4dd20b979be49d9912a7bd94bc1c78467eaf69b Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Thu, 4 Oct 2007 21:58:10 +0000 Subject: [PATCH] Fixed CustomRequiredFields (merged from 2.1.0-textme branch, r42959) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43116 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/CustomRequiredFields.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/forms/CustomRequiredFields.php b/forms/CustomRequiredFields.php index 570067bb4..40c871931 100755 --- a/forms/CustomRequiredFields.php +++ b/forms/CustomRequiredFields.php @@ -31,14 +31,11 @@ class CustomRequiredFields extends RequiredFields{ if(is_array($this->required)){ foreach($this->required as $field) { - if($fields->dataFieldByName($field)) { - if(is_array($field) && $field['js']){ - $code .= $field['js'] . "\n"; - - }else{ - $code .= " require('$field');\n"; - //Tabs for output tabbing :-) - } + if(is_array($field) && $field['js']){ + $code .= $field['js'] . "\n"; + }else if($fields->dataFieldByName($field)) { + $code .= " require('$field');\n"; + //Tabs for output tabbing :-) } } }else{ @@ -59,15 +56,13 @@ class CustomRequiredFields extends RequiredFields{ } if($this->required){ foreach($this->required as $key => $field) { - if($fields->dataFieldByName($field)) { - if(is_array($field) && $field['php']){ - eval($field['php']); - }else{ - // if an error is found, the form is returned. - if(!$data[$field]) { - $this->validationError($field,"$field is required","required"); - return false; - } + if(is_array($field) && $field['php']){ + eval($field['php']); + }else if($fields->dataFieldByName($field)) { + // if an error is found, the form is returned. + if(!$data[$field]) { + $this->validationError($field,"$field is required","required"); + return false; } } }