summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-01-24 00:40:46 +0000
committerxue <>2006-01-24 00:40:46 +0000
commit8315c49b766ae0ae4c6729f641f6c83c50636b6c (patch)
tree39c700e7d6097ca6b70147952038f470ee799167
parent4282256a7bf5580cd0fa22ce9686024352f23a6f (diff)
Fixed a few issues with TCheckBox about validator.
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.page42
-rw-r--r--framework/Web/UI/TPage.php2
-rw-r--r--framework/Web/UI/TTemplateManager.php3
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php10
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php9
-rw-r--r--framework/Web/UI/WebControls/TRequiredFieldValidator.php2
6 files changed, 49 insertions, 19 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.page
index 9e25fc8e..5b59e22b 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TCheckBox/Home.page
@@ -31,7 +31,6 @@ An auto postback checkbox:
</td><td class="sampleaction">
<com:TCheckBox
AutoPostBack="true"
- ValidationGroup="t"
Text="click me"
OnCheckedChanged="checkboxClicked"
/>
@@ -47,7 +46,46 @@ A checkbox causing validation on a textbox:
ErrorMessage="input required in the textbox"
ValidationGroup="Group"
/>
-<com:TCheckBox Text="submit" ValidationGroup="Group" />
+<com:TCheckBox
+ Text="submit"
+ AutoPostBack="true"
+ ValidationGroup="Group"
+ />
+</td></tr>
+
+<tr><td class="samplenote">
+A checkbox validated by a required field validator:
+</td><td class="sampleaction">
+<com:TCheckBox
+ ID="CheckBox"
+ Text="Consent"
+ ValidationGroup="Group2"
+ />
+<com:TButton Text="Submit" ValidationGroup="Group2" />
+<com:TRequiredFieldValidator
+ ControlToValidate="CheckBox"
+ Display="Dynamic"
+ ErrorMessage="You must consent."
+ ValidationGroup="Group2"
+ />
+</td></tr>
+
+<tr><td class="samplenote">
+A checkbox validated by a required field validator using AutoPostBack:
+</td><td class="sampleaction">
+<com:TCheckBox
+ ID="CheckBox2"
+ Text="Agree"
+ Checked="true"
+ AutoPostBack="true"
+ ValidationGroup="Group3"
+ />
+<com:TRequiredFieldValidator
+ ControlToValidate="CheckBox2"
+ Display="Dynamic"
+ ErrorMessage="You must agree."
+ ValidationGroup="Group3"
+ />
</td></tr>
</table>
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 1dfc3b1e..53090e7f 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -288,8 +288,10 @@ class TPage extends TTemplateControl
{
Prado::trace("Page validate",'System.Web.UI.TPage');
foreach($this->_validators as $validator)
+ {
if($validator->getValidationGroup()===$validationGroup)
$validator->validate();
+ }
}
}
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 0205fb7f..07e27891 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -735,7 +735,8 @@ class TTemplate extends TComponent implements ITemplate
throw new TTemplateParsingException('template_event_forbidden',$name);
else
{
- if(!is_callable(array($className,'set'.$name)))
+ // id is still alowed for TComponent, even if id property doesn't exist
+ if(strcasecmp($name,'id')!==0 && !is_callable(array($className,'set'.$name)))
{
if(is_callable(array($className,'get'.$name)))
throw new TTemplateParsingException('template_property_readonly',$name);
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index af8eb7e9..5110230b 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -154,7 +154,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
$scriptKey = "TBaseValidator:$formID";
if($this->getEnableClientScript() && !$scripts->isEndScriptRegistered($scriptKey))
{
- $scripts->registerClientScript('validator');
+ $scripts->registerClientScript('validator');
$scripts->registerEndScript($scriptKey, "Prado.Validation.AddForm('$formID');");
}
if($this->getEnableClientScript())
@@ -361,13 +361,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
protected function getValidationValue($control)
{
if($control instanceof IValidatable)
- {
- $value=$control->getValidationPropertyValue();
- //if($value instanceof TListItem)
- // return $value->getValue();
- //else
- return TPropertyValue::ensureString($value);
- }
+ return $control->getValidationPropertyValue();
else
throw new TInvalidDataTypeException('basevalidator_validatable_required');
}
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index 47fabd20..98084009 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -76,13 +76,8 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
*/
public function raisePostDataChangedEvent()
{
- $page=$this->getPage();
- if($this->getAutoPostBack() && !$page->getPostBackEventTarget())
- {
- $page->setPostBackEventTarget($this);
- if($this->getCausesValidation())
- $page->validate($this->getValidationGroup());
- }
+ if($this->getAutoPostBack() && $this->getCausesValidation())
+ $this->getPage()->validate($this->getValidationGroup());
$this->onCheckedChanged(null);
}
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
index df6c2abf..702fc5d2 100644
--- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php
+++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
@@ -58,7 +58,7 @@ class TRequiredFieldValidator extends TBaseValidator
protected function evaluateIsValid()
{
$value=$this->getValidationValue($this->getValidationTarget());
- return trim($value)!==trim($this->getInitialValue());
+ return trim($value)!==trim($this->getInitialValue()) || (is_bool($value) && $value);
}
/**