From 6228873cf9d6471463d2413e7dfd7447f759baf2 Mon Sep 17 00:00:00 2001 From: "christophe.boulain" <> Date: Wed, 3 Dec 2008 14:22:03 +0000 Subject: Merge from trunk --- framework/Web/UI/WebControls/TCustomValidator.php | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'framework/Web/UI/WebControls/TCustomValidator.php') diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index e998cef6..0b82ac5c 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -4,7 +4,7 @@ * * @author Qiang Xue * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft * @license http://www.pradosoft.com/license/ * @version $Id$ * @package System.Web.UI.WebControls @@ -88,7 +88,9 @@ class TCustomValidator extends TBaseValidator */ public function evaluateIsValid() { - $value=$this->getValidationValue($this->getValidationTarget()); + $value = ''; + if($this->getValidationTarget()!==null) + $value=$this->getValidationValue($this->getValidationTarget()); return $this->onServerValidate($value); } @@ -105,9 +107,24 @@ class TCustomValidator extends TBaseValidator { $param=new TServerValidateEventParameter($value,true); $this->raiseEvent('OnServerValidate',$this,$param); - return $param->getIsValid(); + if($this->getValidationTarget()==null) + return true; + else + return $param->getIsValid(); + } + + /** + * @return TControl control to be validated. Null if no control is found. + */ + protected function getValidationTarget() + { + if(($id=$this->getControlToValidate())!=='' && ($control=$this->findControl($id))!==null) + return $control; + else if(($id=$this->getControlToValidate())!=='') + throw new TInvalidDataTypeException('basevalidator_validatable_required',get_class($this)); + else + return null; } - /** * Returns an array of javascript validator options. @@ -191,4 +208,3 @@ class TServerValidateEventParameter extends TEventParameter $this->_isValid=TPropertyValue::ensureBoolean($value); } } -?> -- cgit v1.2.3