From fe60cc221f922ea362826e2d00431c5df28fe85f Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 6 Oct 2006 03:46:05 +0000 Subject: fixed #410 #412 --- .../UI/ActiveControls/TActiveCustomValidator.php | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'framework/Web/UI/ActiveControls/TActiveCustomValidator.php') diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php index 686149eb..0a6b7b84 100644 --- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php +++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php @@ -10,6 +10,8 @@ * @package System.Web.UI.ActiveControls */ +Prado::using('System.Web.UI.ActiveControls.TCallbackClientSide'); + /** * TActiveCustomValidator Class * @@ -55,6 +57,7 @@ class TActiveCustomValidator extends TCustomValidator { parent::__construct(); $this->setAdapter(new TActiveControlAdapter($this)); + $this->getActiveControl()->setClientSide(new TActiveCustomValidatorClientSide); } /** @@ -65,6 +68,14 @@ class TActiveCustomValidator extends TCustomValidator return $this->getAdapter()->getBaseActiveControl(); } + /** + * @return TCallbackClientSide client side request options. + */ + public function getClientSide() + { + return $this->getAdapter()->getBaseActiveControl()->getClientSide(); + } + /** * Client validation function is NOT supported. */ @@ -131,4 +142,67 @@ class TActiveCustomValidator extends TCustomValidator } } +/** + * Custom Validator callback client side options class. + * + * @author Wei Zhuo + * @version $Id$ + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TActiveCustomValidatorClientSide extends TCallbackClientSide +{ + /** + * @return string javascript code for client-side OnValidate event. + */ + public function getOnValidate() + { + return $this->getOption('OnValidate'); + } + + /** + * Client-side OnValidate validator event is raise before the validators + * validation functions are called. + * @param string javascript code for client-side OnValidate event. + */ + public function setOnValidate($javascript) + { + $this->setFunction('OnValidate', $javascript); + } + + /** + * Client-side OnError event is raised after validation failure. + * This will override the default client-side validator behaviour. + * @param string javascript code for client-side OnError event. + */ + public function setOnError($javascript) + { + $this->setFunction('OnError', $javascript); + } + + /** + * @return string javascript code for client-side OnError event. + */ + public function getOnError() + { + return $this->getOption('OnError'); + } + + /** + * @param boolean true to revalidate when the control to validate changes value. + */ + public function setObserveChanges($value) + { + $this->setOption('ObserveChanges', TPropertyValue::ensureBoolean($value)); + } + + /** + * @return boolean true to observe changes. + */ + public function getObserveChanges() + { + $changes = $this->getOption('ObserveChanges'); + return is_null($changes) ? true : $changes; + } +} ?> \ No newline at end of file -- cgit v1.2.3