From 132f4ae5caefb642fd0676526a3fc08743cdcdf5 Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Thu, 30 Oct 2008 01:02:57 +0000 Subject: [PATCH] CurrencyField::jsValidation() needs to register its validateCurrency function mulitiple times with different FormID for working in a popup of ComplexTableField where FormID is changed. In general all Form Fields should imply with this rule if a page contain mulitiple forms, but this is not under our current developing cycle, since our form fields validation is changing to use jQuery. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64896 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/CurrencyField.php | 6 ++++-- forms/DateField.php | 14 ++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/forms/CurrencyField.php b/forms/CurrencyField.php index ff44efc8f..fa647513e 100755 --- a/forms/CurrencyField.php +++ b/forms/CurrencyField.php @@ -60,9 +60,11 @@ Behaviour.register({ }); JS; - Requirements::customScript($jsFunc, 'func_validateCurrency'); + Requirements::customScript($jsFunc, 'func_validateCurrency_' .$formID); - return "\$('$formID').validateCurrency('$this->name');"; + return <<name'); +JS; } function validate($validator) { diff --git a/forms/DateField.php b/forms/DateField.php index bf76c9f27..528d19da2 100755 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -57,15 +57,17 @@ Behaviour.register({ } }); JS; - Requirements :: customScript($jsFunc, 'func_validateDate'); + Requirements :: customScript($jsFunc, 'func_validateDate_'.$formID); // return "\$('$formID').validateDate('$this->name');"; return <<name') - $('$formID').validateDate('$this->name'); -}else{ - $('$formID').validateDate('$this->name'); +if(\$('$formID')){ + if(typeof fromAnOnBlur != 'undefined'){ + if(fromAnOnBlur.name == '$this->name') + \$('$formID').validateDate('$this->name'); + }else{ + \$('$formID').validateDate('$this->name'); + } } JS; }