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
This commit is contained in:
Andrew O'Neil 2007-10-04 21:58:10 +00:00
parent a181f7c151
commit f4dd20b979

View File

@ -31,16 +31,13 @@ class CustomRequiredFields extends RequiredFields{
if(is_array($this->required)){ if(is_array($this->required)){
foreach($this->required as $field) { foreach($this->required as $field) {
if($fields->dataFieldByName($field)) {
if(is_array($field) && $field['js']){ if(is_array($field) && $field['js']){
$code .= $field['js'] . "\n"; $code .= $field['js'] . "\n";
}else if($fields->dataFieldByName($field)) {
}else{
$code .= " require('$field');\n"; $code .= " require('$field');\n";
//Tabs for output tabbing :-) //Tabs for output tabbing :-)
} }
} }
}
}else{ }else{
USER_ERROR("CustomRequiredFields::requiredfields is not set / not an array",E_USER_WARNING); USER_ERROR("CustomRequiredFields::requiredfields is not set / not an array",E_USER_WARNING);
} }
@ -59,10 +56,9 @@ class CustomRequiredFields extends RequiredFields{
} }
if($this->required){ if($this->required){
foreach($this->required as $key => $field) { foreach($this->required as $key => $field) {
if($fields->dataFieldByName($field)) {
if(is_array($field) && $field['php']){ if(is_array($field) && $field['php']){
eval($field['php']); eval($field['php']);
}else{ }else if($fields->dataFieldByName($field)) {
// if an error is found, the form is returned. // if an error is found, the form is returned.
if(!$data[$field]) { if(!$data[$field]) {
$this->validationError($field,"$field is required","required"); $this->validationError($field,"$field is required","required");
@ -71,7 +67,6 @@ class CustomRequiredFields extends RequiredFields{
} }
} }
} }
}
return $valid; return $valid;
} }