summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TRequiredFieldValidator.php
diff options
context:
space:
mode:
authorxue <>2006-07-07 14:54:15 +0000
committerxue <>2006-07-07 14:54:15 +0000
commit61bb16ee2e5f0a66234e1575242169a10fde47b5 (patch)
tree3ee24dcc36ceae2c213130df1ea3d5c9fc110a27 /framework/Web/UI/WebControls/TRequiredFieldValidator.php
parent7b84938b1b5964f2274d66e28ba17435924ffe35 (diff)
Merge from 3.0 branch till 1253.
Diffstat (limited to 'framework/Web/UI/WebControls/TRequiredFieldValidator.php')
-rw-r--r--framework/Web/UI/WebControls/TRequiredFieldValidator.php49
1 files changed, 38 insertions, 11 deletions
diff --git a/framework/Web/UI/WebControls/TRequiredFieldValidator.php b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
index b8a939ad..c99d9c19 100644
--- a/framework/Web/UI/WebControls/TRequiredFieldValidator.php
+++ b/framework/Web/UI/WebControls/TRequiredFieldValidator.php
@@ -76,22 +76,47 @@ class TRequiredFieldValidator extends TBaseValidator
protected function evaluateIsValid()
{
$control = $this->getValidationTarget();
- $initial = trim($this->getInitialValue());
if($control instanceof TListControl)
+ return $this->validateListControl($control);
+ else if($control instanceof TRadioButton && strlen($control->getGroupName()) > 0)
+ return $this->validateRadioButtonGroup($control);
+ else
+ return $this->validateStandardControl($control);
+ }
+
+ private function validateListControl($control)
+ {
+ $initial = trim($this->getInitialValue());
+ $count = 0;
+ foreach($control->getItems() as $item)
{
- $count = 0;
- foreach($control->getItems() as $item)
- {
- if($item->getSelected() && $item->getValue() != $initial)
- $count++;
- }
- return $count > 0;
+ if($item->getSelected() && $item->getValue() != $initial)
+ $count++;
}
- else
+ return $count > 0;
+ }
+
+ private function validateRadioButtonGroup($control)
+ {
+ $initial = trim($this->getInitialValue());
+ foreach($control->getRadioButtonsInGroup() as $radio)
{
- $value=$this->getValidationValue($control);
- return trim($value)!==$initial || (is_bool($value) && $value);
+ if($radio->getChecked())
+ {
+ if(strlen($value = $radio->getValue()) > 0)
+ return $value !== $initial;
+ else
+ return true;
+ }
}
+ return false;
+ }
+
+ private function validateStandardControl($control)
+ {
+ $initial = trim($this->getInitialValue());
+ $value=$this->getValidationValue($control);
+ return trim($value)!==$initial || (is_bool($value) && $value);
}
/**
@@ -105,6 +130,8 @@ class TRequiredFieldValidator extends TBaseValidator
$control = $this->getValidationTarget();
if($control instanceof TListControl)
$options['TotalItems'] = $control->getItemCount();
+ if($control instanceof TRadioButton && strlen($control->getGroupName()) > 0)
+ $options['GroupName'] = $control->getGroupName();
return $options;
}
}