summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TCustomValidator.php
diff options
context:
space:
mode:
authorcarlgmathisen <>2008-10-30 17:07:05 +0000
committercarlgmathisen <>2008-10-30 17:07:05 +0000
commitefc2ce4a4e469085a10a424f2fd09ce688fb6b31 (patch)
tree6f0aef272f4ea2c9857dc12c15d5e9efa5d4cf2e /framework/Web/UI/WebControls/TCustomValidator.php
parent4baf17880e3c83b6900794459d2ebb9adf379aa3 (diff)
Issue 39 - Implement validator not requiring ControlToValidate
Diffstat (limited to 'framework/Web/UI/WebControls/TCustomValidator.php')
-rw-r--r--framework/Web/UI/WebControls/TCustomValidator.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php
index fe540c80..0b82ac5c 100644
--- a/framework/Web/UI/WebControls/TCustomValidator.php
+++ b/framework/Web/UI/WebControls/TCustomValidator.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 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.