From a26837b0990f65b7091263026296d2aff68d9838 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Wed, 18 Jan 2012 09:35:07 +0000 Subject: fixed #380 (TCustomValidator's ControlToValidate should be optional); added a quickstart example, updated 2 tests that were broken + HISTORY --- framework/Web/UI/WebControls/TBaseValidator.php | 11 ++++++++--- framework/Web/UI/WebControls/TCustomValidator.php | 5 +---- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index c90f4d9d..6e4e8f71 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -163,7 +163,8 @@ abstract class TBaseValidator extends TLabel implements IValidator $options['FocusElementID'] = $this->getFocusElementID(); } $options['ValidationGroup'] = $this->getValidationGroup(); - $options['ControlToValidate'] = $control->getClientID(); + if($control) + $options['ControlToValidate'] = $control->getClientID(); $options['ControlCssClass'] = $this->getControlCssClass(); $options['ControlType'] = $this->getClientControlClass($control); @@ -499,8 +500,11 @@ abstract class TBaseValidator extends TLabel implements IValidator $this->onValidate(); if($this->getVisible(true) && $this->getEnabled(true)) { + $target=$this->getValidationTarget(); // if the target is not a disabled web control - if(($target=$this->getValidationTarget())!==null && !($target instanceof TWebControl && !$target->getEnabled(true))) + if($target===null || + ($target!==null && + !($target instanceof TWebControl && !$target->getEnabled(true)))) { if($this->evaluateIsValid()) { @@ -509,7 +513,8 @@ abstract class TBaseValidator extends TLabel implements IValidator } else { - $target->setIsValid(false); + if($target) + $target->setIsValid(false); $this->setIsValid(false); $this->onValidationError(); } diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index 7d0c8234..cc11c7a6 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -107,10 +107,7 @@ class TCustomValidator extends TBaseValidator { $param=new TServerValidateEventParameter($value,true); $this->raiseEvent('OnServerValidate',$this,$param); - if($this->getValidationTarget()==null) - return true; - else - return $param->getIsValid(); + return $param->getIsValid(); } /** -- cgit v1.2.3