From d5950ec0b553d46c4800adc0532d4464a4eb1883 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Tue, 27 Mar 2007 08:34:28 +0000
Subject: Fixed #278, conditional validation.
---
.gitattributes | 5 ++
.../Controls/Samples/ResetValidation/Home.page | 25 +++++++++
.../Controls/Samples/ResetValidation/Home.php | 8 +++
.../Samples/TClientSideValidator/Home.page | 63 ++++++++++------------
.../Controls/Samples/TClientSideValidator/Home.php | 18 +++----
.../protected/pages/Controls/Validation.page | 31 +++++++----
.../pages/GettingStarted/Introduction.page | 3 +-
framework/Web/UI/WebControls/TBaseValidator.php | 2 +-
.../protected/pages/ConditionalValidation.page | 30 +++++++++++
.../protected/pages/ConditionalValidation.php | 20 +++++++
.../tests/ConditionalValidationTestCase.php | 55 +++++++++++++++++++
11 files changed, 203 insertions(+), 57 deletions(-)
create mode 100644 demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page
create mode 100644 demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php
create mode 100644 tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page
create mode 100644 tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php
create mode 100644 tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php
diff --git a/.gitattributes b/.gitattributes
index be7efd73..ec41c3e0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1043,6 +1043,8 @@ demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/LabeledTextBox
demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/Home.page -text
demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox2/LabeledTextBox.php -text
+demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page -text
+demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.page -text
demos/quickstart/protected/pages/Controls/Samples/TBulletedList/Home.php -text
demos/quickstart/protected/pages/Controls/Samples/TBulletedList/bullet.gif -text
@@ -2428,6 +2430,8 @@ tests/FunctionalTests/validators/protected/pages/CausesValidation.page -text
tests/FunctionalTests/validators/protected/pages/CheckBox.page -text
tests/FunctionalTests/validators/protected/pages/CheckBox.php -text
tests/FunctionalTests/validators/protected/pages/CompareValidator.page -text
+tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page -text
+tests/FunctionalTests/validators/protected/pages/ConditionalValidation.php -text
tests/FunctionalTests/validators/protected/pages/CustomValidator.page -text
tests/FunctionalTests/validators/protected/pages/CustomValidator.php -text
tests/FunctionalTests/validators/protected/pages/DataTypeValidator.page -text
@@ -2452,6 +2456,7 @@ tests/FunctionalTests/validators/protected/pages/config.xml -text
tests/FunctionalTests/validators/tests/ButtonTestCase.php -text
tests/FunctionalTests/validators/tests/CheckBoxTestCase.php -text
tests/FunctionalTests/validators/tests/CompareValidatorTestCase.php -text
+tests/FunctionalTests/validators/tests/ConditionalValidationTestCase.php -text
tests/FunctionalTests/validators/tests/CustomValidatorTestCase.php -text
tests/FunctionalTests/validators/tests/DataTypeValidatorTestCase.php -text
tests/FunctionalTests/validators/tests/DatePickerTestCase.php -text
diff --git a/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page
new file mode 100644
index 00000000..44f84abe
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page
@@ -0,0 +1,25 @@
+Reset Validation using Javascript
+
+
+
+
+
+
+
+
+
+Validator with default settings:
+
+
+
+Validator Toggle - Server and Client Side
- Conditional Validation (client-side + server side)
-
-Validators can be reset on the client-side using javascript by calling the -Prado.Validation.reset(groupID) where groupID is the validator -grouping name. If groupID is null, then validators without grouping are used. -
- +@@ -159,6 +152,24 @@ The summary can be displayed as a list, a bulleted list, or a single paragraph b
+Validators can be reset on the client-side using javascript by calling the +Prado.Validation.reset(groupID) where groupID is the validator +grouping name. If groupID is null, then validators without grouping are used. +
+ +All validators contains the following events. @@ -191,7 +202,9 @@ is the control that invoked the validator.
The following example show the use of client-side and server side validator events. The example
-demonstrates conditional validation.
+demonstrates conditional validation. Notice that, we need to write code for both the
+server side and client-side. Moreover, on the server side, we need to re-enable the conditional
+validator so that its javascript code are produced no matter what (otherwise, the client-side validator is not available).
If you are an existing PRADO 3.x user and would like to learn what enhancements are available for each new version, please check out the new features page. Otherwise, the following sections are helpful for newbies.
+
You may refer to the following resources if you find this tutorial does not fulfill all your needs.
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index ac2d53b8..99a81375 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -483,9 +483,9 @@ abstract class TBaseValidator extends TLabel implements IValidator
public function validate()
{
$this->setIsValid(true);
+ $this->onValidate();
if($this->getVisible(true) && $this->getEnabled(true))
{
- $this->onValidate();
if($this->getValidationTarget())
{
if($this->evaluateIsValid())
diff --git a/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page
new file mode 100644
index 00000000..ad43135b
--- /dev/null
+++ b/tests/FunctionalTests/validators/protected/pages/ConditionalValidation.page
@@ -0,0 +1,30 @@
+Conditional Validation (clientside + server side)
+