From f4169ef12e83b93d9693c3e9278af6a6f02861d6 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 27 May 2006 04:29:26 +0000 Subject: Fixed #169. --- .gitattributes | 3 +++ framework/Web/Javascripts/prado/validation3.js | 4 +++- framework/Web/UI/WebControls/TBaseValidator.php | 24 +++++++++++++++++++++- .../tickets/protected/pages/TestHtmlArea.php | 8 ++++++++ .../tickets/protected/pages/Ticket169.page | 8 ++++++++ .../tickets/tests/Ticket169TestCase.php | 14 +++++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tests/FunctionalTests/tickets/protected/pages/TestHtmlArea.php create mode 100644 tests/FunctionalTests/tickets/protected/pages/Ticket169.page create mode 100644 tests/FunctionalTests/tickets/tests/Ticket169TestCase.php diff --git a/.gitattributes b/.gitattributes index 07dc529a..14c4031f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1046,9 +1046,11 @@ tests/FunctionalTests/tickets.php -text tests/FunctionalTests/tickets/index.php -text tests/FunctionalTests/tickets/protected/pages/Layout.php -text tests/FunctionalTests/tickets/protected/pages/Layout.tpl -text +tests/FunctionalTests/tickets/protected/pages/TestHtmlArea.php -text tests/FunctionalTests/tickets/protected/pages/Ticket121.page -text tests/FunctionalTests/tickets/protected/pages/Ticket121.php -text tests/FunctionalTests/tickets/protected/pages/Ticket163.page -text +tests/FunctionalTests/tickets/protected/pages/Ticket169.page -text tests/FunctionalTests/tickets/protected/pages/Ticket191.page -text tests/FunctionalTests/tickets/protected/pages/Ticket191.php -text tests/FunctionalTests/tickets/protected/pages/Ticket21.page -text @@ -1068,6 +1070,7 @@ tests/FunctionalTests/tickets/protected/pages/config.xml -text tests/FunctionalTests/tickets/protected/pages/hotspot.jpg -text tests/FunctionalTests/tickets/tests/Ticket121TestCase.php -text tests/FunctionalTests/tickets/tests/Ticket163TestCase.php -text +tests/FunctionalTests/tickets/tests/Ticket169TestCase.php -text tests/FunctionalTests/tickets/tests/Ticket191TestCase.php -text tests/FunctionalTests/tickets/tests/Ticket21TestCase.php -text tests/FunctionalTests/tickets/tests/Ticket27TestCase.php -text diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 8b6b19fc..396b4356 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -754,7 +754,9 @@ Prado.WebUI.TBaseValidator.prototype = return value; }, - /** + /** + * The ControlType property comes from TBaseValidator::getClientControlClass() + * Be sure to update the TBaseValidator::$_clientClass if new cases are added. * @return mixed control value to validate */ getValidationValue : function(control) diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 8fcba1c2..9ff2a97d 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -83,6 +83,12 @@ abstract class TBaseValidator extends TLabel implements IValidator * @var TValidatorClientScript validator client-script options. */ private $_clientScript; + /** + * Controls for which the client-side validation3.js file needs to handle + * them specially. + * @var array list of control class names + */ + private static $_clientClass = array('THtmlArea', 'TDatePicker'); /** * Constructor. @@ -152,7 +158,8 @@ abstract class TBaseValidator extends TLabel implements IValidator $options['ValidationGroup'] = $this->getValidationGroup(); $options['ControlToValidate'] = $control->getClientID(); $options['ControlCssClass'] = $this->getControlCssClass(); - $options['ControlType'] = get_class($control); + + $options['ControlType'] = $this->getClientControlClass($control); if(!is_null($this->_clientScript)) $options = array_merge($options,$this->_clientScript->getOptions()); @@ -160,6 +167,21 @@ abstract class TBaseValidator extends TLabel implements IValidator return $options; } + /** + * Gets the Control type for client-side validation. If new cases exists in + * TBaseValidator::$_clientClass, be sure to update the corresponding + * "Javascript/validation3.js" file as well. + * @param TControl control to validate. + * @return string control type for client-side validation. + */ + private function getClientControlClass($control) + { + foreach(self::$_clientClass as $type) + if($control instanceof $type) + return $type; + return get_class($control); + } + /** * Gets the TValidatorClientScript that allows modification of the client- * side validator events. diff --git a/tests/FunctionalTests/tickets/protected/pages/TestHtmlArea.php b/tests/FunctionalTests/tickets/protected/pages/TestHtmlArea.php new file mode 100644 index 00000000..13a4189b --- /dev/null +++ b/tests/FunctionalTests/tickets/protected/pages/TestHtmlArea.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket169.page b/tests/FunctionalTests/tickets/protected/pages/Ticket169.page new file mode 100644 index 00000000..24c447d5 --- /dev/null +++ b/tests/FunctionalTests/tickets/protected/pages/Ticket169.page @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/tests/FunctionalTests/tickets/tests/Ticket169TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket169TestCase.php new file mode 100644 index 00000000..30bbc92d --- /dev/null +++ b/tests/FunctionalTests/tickets/tests/Ticket169TestCase.php @@ -0,0 +1,14 @@ +open('tickets/index.php?page=Ticket169'); + $this->assertNotVisible('ctl0_Content_validator1'); + $this->click('ctl0_Content_ctl0'); + $this->assertVisible('ctl0_Content_validator1'); + } +} + +?> \ No newline at end of file -- cgit v1.2.3