diff options
author | ctrlaltca@gmail.com <> | 2012-01-18 09:35:07 +0000 |
---|---|---|
committer | ctrlaltca@gmail.com <> | 2012-01-18 09:35:07 +0000 |
commit | a26837b0990f65b7091263026296d2aff68d9838 (patch) | |
tree | 3eea57ec60f9c7136a42183e1f6d057a0a1bc997 | |
parent | e3e61542d5a5292b12c987998326f686a5e11d81 (diff) |
fixed #380 (TCustomValidator's ControlToValidate should be optional); added a quickstart example, updated 2 tests that were broken + HISTORY
9 files changed, 49 insertions, 25 deletions
@@ -61,6 +61,7 @@ BUG: Issue #371 - Sorting on TActiveDataGrid autogenerated column not work (ctrl ENH: Issue #372 - ActiveControls's Visible property should be reflected clientside on ajax requests (ctrlaltca) BUG: Issue #375 - Iconv error using htmlarea in TActiveDataList and chars like "áéíóúñ" (ctrlaltca) BUG: Issue #377 - THtmlArea Template Pluggin Options Parse Error (ctrlaltca) +BUG: Issue #380 - TCustomValidator's ControlToValidate should be optional (ctrlaltca) Version 3.1.10 Jul 17, 2011 BUG: Added missing timeout on TCacheHttpSession (ctrlaltca) @@ -20,14 +20,14 @@ Upgrading from v3.1.x and the entire TClientScriptLoader class. These two were used to publish multiple javascript files at once and to compress/minify them. While the compression is something that is probably better done at the webserver/processor level, you can still get your scripts minified using TJavaScript::JSMin(); -- Ticket #325 enabled pregressive rendering inside Prado. Previously, all the output of Prado was - buffered and sent to the client all at once. Now, you decide to render smaller parts of the page +- Ticket #325 enabled progressive rendering inside Prado. Previously, all the output of Prado was + buffered and sent to the client all at once. Now, you can decide to render smaller parts of the page and send them to client right after completed, one after the other (see TFlushOutput documentation). To ensure proper working of components requiring "head" resources (like external javascript files), all the resource publishing needs to be made before the actual rendering occurs. Tipically the best idea is to do it inside the onPreRender event. All the Prado components have been (obviously) updated to support this change, but any custom component made by yourself could need some update efforts. - The easist way to understand if a component is broken because of this change is to check if you get a + The easiest way to understand if a component is broken because of this change is to check if you get a 'Operation invalid when page is already rendering' exception. - A new "TReCaptcha" control has been added to overcome the limited security offered by TCaptcha. If you are currently using TCaptcha, an update to the new control is really adviced. diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.page index 7c1bccfe..65195a55 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.page +++ b/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.page @@ -64,6 +64,19 @@ Custom validator with focus-on-error enabled and dynamic display: </td>
</tr>
+<tr>
+<td class="samplenote">
+Custom validator without ControlToValidate:
+</td>
+<td class="sampleaction">
+<com:TTextBox ID="TextBox4" />
+<com:TCustomValidator
+ ValidationGroup="Group4"
+ OnServerValidate="serverValidateNoControl"
+ Text="You must enter 'test'." />
+<com:TButton Text="Submit" ValidationGroup="Group4" />
+</td>
+</tr>
</table>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php index 0db261b9..da0d15b2 100644 --- a/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php +++ b/demos/quickstart/protected/pages/Controls/Samples/TCustomValidator/Home.php @@ -7,6 +7,12 @@ class Home extends TPage if($param->Value!=='test')
$param->IsValid=false;
}
+
+ public function serverValidateNoControl($sender,$param)
+ {
+ if($this->TextBox4->Text!=='test')
+ $param->IsValid=false;
+ }
}
?>
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index c90f4d9d..6e4e8f71 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -163,7 +163,8 @@ abstract class TBaseValidator extends TLabel implements IValidator $options['FocusElementID'] = $this->getFocusElementID();
}
$options['ValidationGroup'] = $this->getValidationGroup();
- $options['ControlToValidate'] = $control->getClientID();
+ if($control)
+ $options['ControlToValidate'] = $control->getClientID();
$options['ControlCssClass'] = $this->getControlCssClass();
$options['ControlType'] = $this->getClientControlClass($control);
@@ -499,8 +500,11 @@ abstract class TBaseValidator extends TLabel implements IValidator $this->onValidate();
if($this->getVisible(true) && $this->getEnabled(true))
{
+ $target=$this->getValidationTarget();
// if the target is not a disabled web control
- if(($target=$this->getValidationTarget())!==null && !($target instanceof TWebControl && !$target->getEnabled(true)))
+ if($target===null ||
+ ($target!==null &&
+ !($target instanceof TWebControl && !$target->getEnabled(true))))
{
if($this->evaluateIsValid())
{
@@ -509,7 +513,8 @@ abstract class TBaseValidator extends TLabel implements IValidator }
else
{
- $target->setIsValid(false);
+ if($target)
+ $target->setIsValid(false);
$this->setIsValid(false);
$this->onValidationError();
}
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php index 7d0c8234..cc11c7a6 100644 --- a/framework/Web/UI/WebControls/TCustomValidator.php +++ b/framework/Web/UI/WebControls/TCustomValidator.php @@ -107,10 +107,7 @@ class TCustomValidator extends TBaseValidator {
$param=new TServerValidateEventParameter($value,true);
$this->raiseEvent('OnServerValidate',$this,$param);
- if($this->getValidationTarget()==null)
- return true;
- else
- return $param->getIsValid();
+ return $param->getIsValid();
}
/**
diff --git a/tests/FunctionalTests/validators/protected/pages/DatePicker.page b/tests/FunctionalTests/validators/protected/pages/DatePicker.page index fdbbbeb1..7dfd2788 100644 --- a/tests/FunctionalTests/validators/protected/pages/DatePicker.page +++ b/tests/FunctionalTests/validators/protected/pages/DatePicker.page @@ -10,8 +10,8 @@ ControlToValidate="picker1"
DataType="Date"
DateFormat="d/M/yyyy"
- ErrorMessage="Please enter a date greater than 17/4/2007"
- MinValue="17/4/2007" />
+ ErrorMessage="Please enter a date greater than 17/4/2013"
+ MinValue="17/4/2013" />
<hr />
<com:TDatePicker ID="picker2" DateFormat="d/M/yyyy" InputMode="DropDownList" />
@@ -21,9 +21,9 @@ ControlToValidate="picker2"
DataType="Date"
DateFormat="d/M/yyyy"
- ErrorMessage="Please enter a date between 9/9/2006 and 8/10/2006"
- MinValue="9/9/2006"
- MaxValue="8/10/2006" />
+ ErrorMessage="Please enter a date between 9/9/2012 and 8/10/2012"
+ MinValue="9/9/2012"
+ MaxValue="8/10/2012" />
<hr />
Date 1:
diff --git a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php index 320802e4..4d848ec8 100644 --- a/tests/FunctionalTests/validators/tests/DatePickerTestCase.php +++ b/tests/FunctionalTests/validators/tests/DatePickerTestCase.php @@ -4,6 +4,8 @@ class DatePickerTestCase extends SeleniumTestCase {
function test()
{
+ $year=2012;
+ $year2=2013;
$base = "ctl0_Content_";
$this->open("validators/index.php?page=DatePicker", "");
$this->verifyTextPresent("Date Picker validation Test", "");
@@ -26,17 +28,17 @@ class DatePickerTestCase extends SeleniumTestCase $this->assertVisible("{$base}validator8", "");
$this->click("{$base}submit1");
- $this->type("{$base}picker1", "13/4/2006");
+ $this->type("{$base}picker1", "13/4/$year");
$this->select("{$base}picker2_month", "label=9");
$this->select("{$base}picker2_day", "label=10");
- $this->select("{$base}picker2_year", "label=2006");
- $this->type("{$base}picker3", "14/4/2006");
- $this->type("{$base}picker4", "7/4/2006");
+ $this->select("{$base}picker2_year", "label=$year");
+ $this->type("{$base}picker3", "14/4/$year");
+ $this->type("{$base}picker4", "7/4/$year");
$this->select("{$base}picker5_day", "label=6");
$this->select("{$base}picker5_month", "label=3");
- $this->select("{$base}picker5_year", "label=2007");
+ $this->select("{$base}picker5_year", "label=$year2");
$this->select("{$base}picker6_month", "label=3");
- $this->select("{$base}picker6_year", "label=2007");
+ $this->select("{$base}picker6_year", "label=$year2");
$this->select("{$base}picker6_day", "label=5");
$this->click("{$base}submit1");
@@ -48,8 +50,8 @@ class DatePickerTestCase extends SeleniumTestCase $this->assertVisible("{$base}validator6", "");
$this->assertVisible("{$base}validator8", "");
- $this->type("{$base}picker1", "20/4/2007");
- $this->type("{$base}picker4", "29/4/2006");
+ $this->type("{$base}picker1", "20/4/$year2");
+ $this->type("{$base}picker4", "29/4/$year");
$this->select("{$base}picker6_day", "label=10");
$this->clickAndWait("{$base}submit1");
diff --git a/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php b/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php index 69d4cc07..c22ecf8b 100644 --- a/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php +++ b/tests/FunctionalTests/validators/tests/RangeValidatorTestCase.php @@ -97,7 +97,7 @@ class RangeValidatorTestCase extends SeleniumTestCase $this->click("//input[@type='submit' and @value='Test']", "");
$this->assertVisible("{$base}validator1", "");
$this->type("{$base}text1", "1/2/2005");
- $this->click("//input[@type='submit' and @value='Test']", "");
+ $this->clickAndWait("//input[@type='submit' and @value='Test']", "");
$this->assertNotVisible("{$base}validator1", "");
$this->clickAndWait("//input[@type='submit' and @value='Test']", "");
$this->assertNotVisible("{$base}validator1", "");
@@ -164,4 +164,4 @@ class RangeValidatorTestCase extends SeleniumTestCase }
}
-?>
\ No newline at end of file +?>
|