summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TRequiredFieldValidator.php
diff options
context:
space:
mode:
authorxue <>2006-01-19 02:54:27 +0000
committerxue <>2006-01-19 02:54:27 +0000
commit5d88ad05e5956071d5904662d133625f157ce230 (patch)
tree9788f5edddb40024256440208ae2f87eef14269b /framework/Web/UI/WebControls/TRequiredFieldValidator.php
parente4a486b62af0895fd690588129de1190ebf7bd12 (diff)
Added documentation to validator controls.
Diffstat (limited to 'framework/Web/UI/WebControls/TRequiredFieldValidator.php')
-rw-r--r--framework/Web/UI/WebControls/TRequiredFieldValidator.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
index c937abf8..2d1dd612 100644
--- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php
+++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
@@ -18,6 +18,9 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
/**
* TRequiredFieldValidator class
*
+ * TRequiredFieldValidator makes the associated input control a required field.
+ * The input control fails validation if its value does not change from
+ * the {@link setInitialValue InitialValue} property upon losing focus.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
@@ -26,27 +29,42 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
*/
class TRequiredFieldValidator extends TBaseValidator
{
+ /**
+ * @return string the initial value of the associated input control. Defaults to empty string.
+ * If the associated input control does not change from this initial value
+ * upon postback, the validation fails.
+ */
public function getInitialValue()
{
$this->getViewState('InitialValue','');
}
+ /**
+ * @param string the initial value of the associated input control.
+ * If the associated input control does not change from this initial value
+ * upon postback, the validation fails.
+ */
public function setInitialValue($value)
{
$this->setViewState('InitialValue',TPropertyValue::ensureString($value),'');
}
+ /**
+ * This method overrides the parent's implementation.
+ * The validation succeeds if the input component changes its data
+ * from the {@link getInitialValue InitialValue} or the input control is not given.
+ * @return boolean whether the validation succeeds
+ */
protected function evaluateIsValid()
{
- if(($control=$this->getValidationTarget())!==null)
- {
- $value=$this->getValidationValue($control);
- return trim($value)!==trim($this->getInitialValue());
- }
- else
- throw new TInvalidDataValueException('requiredfieldvalidator_controltovalidate_invalid');
+ $value=$this->getValidationValue($this->getValidationTarget());
+ return trim($value)!==trim($this->getInitialValue());
}
+ /**
+ * Returns an array of javascript validator options.
+ * @return array javascript validator options.
+ */
protected function getClientScriptOptions()
{
$options = parent::getClientScriptOptions();