summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/UI/TControl.php8
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php6
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php18
-rw-r--r--framework/Web/UI/WebControls/TCheckBoxList.php18
-rw-r--r--framework/Web/UI/WebControls/TDropDownList.php18
-rw-r--r--framework/Web/UI/WebControls/TFileUpload.php19
-rw-r--r--framework/Web/UI/WebControls/THiddenField.php18
-rw-r--r--framework/Web/UI/WebControls/TListBox.php18
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php18
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php11
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket595TestCase.php4
12 files changed, 153 insertions, 4 deletions
diff --git a/HISTORY b/HISTORY
index 0e5c3adb..c039aff6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -38,6 +38,7 @@ ENH: Ticket#848 - TCache "set" and "add" with empty values (Carl)
ENH: Ticket#756 - TDateFormat & TNumberFormat - allow settings default text when Value isn't set. (Carl)
ENH: Ticket#822 - Not receiving emails from TEmailLogRoute (Carl)
ENH: Ticket#913 - PRADO Copyright notice in HTML source (Carl)
+BUG: Ticket#595 - ControlCssClass not applied correctly if using multiple validators on same control (Michael)
Version 3.1.2 April 21, 2008
============================
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 576db89b..1c03a04d 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -1997,6 +1997,14 @@ interface IValidatable
* @return mixed the value of the property to be validated.
*/
public function getValidationPropertyValue();
+ /**
+ * @return boolean wether this control's validators validated successfully (must default to true)
+ */
+ public function getIsValid();
+ /**
+ * @return boolean wether this control's validators validated successfully
+ */
+ public function setIsValid($value);
}
/**
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index add771cc..9a298adb 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -269,8 +269,11 @@ abstract class TBaseValidator extends TLabel implements IValidator
{
$class = preg_replace ('/ '.preg_quote($cssClass).'/', '',$control->getCssClass());
if(!$this->getIsValid())
+ {
$class .= ' '.$cssClass;
- $control->setCssClass($class);
+ $control->setCssClass($class);
+ } elseif ($control->getIsValid())
+ $control->setCssClass($class);
}
}
}
@@ -504,6 +507,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
}
else
{
+ $target->setIsValid(false);
$this->setIsValid(false);
$this->onValidationError();
}
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index faff5086..d8c2cc0b 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -43,6 +43,7 @@
class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer, ISurroundable
{
private $_dataChanged=false;
+ private $_isValid=true;
/**
* @return string tag name of the button
@@ -125,6 +126,23 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
return $this->getChecked();
}
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
+
/**
* @return string the text caption of the checkbox
*/
diff --git a/framework/Web/UI/WebControls/TCheckBoxList.php b/framework/Web/UI/WebControls/TCheckBoxList.php
index 1e1c3b10..7cabb356 100644
--- a/framework/Web/UI/WebControls/TCheckBoxList.php
+++ b/framework/Web/UI/WebControls/TCheckBoxList.php
@@ -53,6 +53,7 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
private $_isEnabled;
private $_changedEventRaised=false;
private $_dataChanged=false;
+ private $_isValid=true;
/**
* Constructor.
@@ -428,6 +429,23 @@ class TCheckBoxList extends TListControl implements IRepeatInfoUser, INamingCont
return $this->getSelectedValue();
}
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
+
/**
* Gets the name of the javascript class responsible for performing postback for this control.
* This method overrides the parent implementation.
diff --git a/framework/Web/UI/WebControls/TDropDownList.php b/framework/Web/UI/WebControls/TDropDownList.php
index f00466d5..627646bb 100644
--- a/framework/Web/UI/WebControls/TDropDownList.php
+++ b/framework/Web/UI/WebControls/TDropDownList.php
@@ -40,6 +40,7 @@ Prado::using('System.Web.UI.WebControls.TListControl');
class TDropDownList extends TListControl implements IPostBackDataHandler, IValidatable
{
private $_dataChanged=false;
+ private $_isValid=true;
/**
* Adds attributes to renderer.
@@ -127,5 +128,22 @@ class TDropDownList extends TListControl implements IPostBackDataHandler, IValid
{
return $this->getSelectedValue();
}
+
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
}
?>
diff --git a/framework/Web/UI/WebControls/TFileUpload.php b/framework/Web/UI/WebControls/TFileUpload.php
index 47d49c0c..3f078f4e 100644
--- a/framework/Web/UI/WebControls/TFileUpload.php
+++ b/framework/Web/UI/WebControls/TFileUpload.php
@@ -59,6 +59,7 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata
*/
private $_errorCode=UPLOAD_ERR_NO_FILE;
private $_dataChanged=false;
+ private $_isValid=true;
/**
* @return string tag name of the file upload control
@@ -255,6 +256,24 @@ class TFileUpload extends TWebControl implements IPostBackDataHandler, IValidata
{
return $this->getFileName();
}
+
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
+
}
?>
diff --git a/framework/Web/UI/WebControls/THiddenField.php b/framework/Web/UI/WebControls/THiddenField.php
index 2fbbcf99..c0aa9c4e 100644
--- a/framework/Web/UI/WebControls/THiddenField.php
+++ b/framework/Web/UI/WebControls/THiddenField.php
@@ -26,6 +26,7 @@
class THiddenField extends TControl implements IPostBackDataHandler, IValidatable, IDataRenderer
{
private $_dataChanged=false;
+ private $_isValid=true;
/**
* @return string tag name of the hidden field.
@@ -111,6 +112,23 @@ class THiddenField extends TControl implements IPostBackDataHandler, IValidatabl
return $this->getValue();
}
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
+
/**
* Raises postdata changed event.
* This method calls {@link onValueChanged} method.
diff --git a/framework/Web/UI/WebControls/TListBox.php b/framework/Web/UI/WebControls/TListBox.php
index 903dbed8..a723020d 100644
--- a/framework/Web/UI/WebControls/TListBox.php
+++ b/framework/Web/UI/WebControls/TListBox.php
@@ -39,6 +39,7 @@ Prado::using('System.Web.UI.WebControls.TListControl');
class TListBox extends TListControl implements IPostBackDataHandler, IValidatable
{
private $_dataChanged=false;
+ private $_isValid=true;
/**
* Adds attribute name-value pairs to renderer.
@@ -220,6 +221,23 @@ class TListBox extends TListControl implements IPostBackDataHandler, IValidatabl
{
return $this->getSelectedValue();
}
+
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
}
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index 3c3e6d0e..7a420e15 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -67,6 +67,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
*/
private $_safeText;
private $_dataChanged=false;
+ private $_isValid=true;
/**
* @return string tag name of the textbox
@@ -243,6 +244,23 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
return $this->getText();
}
+ /**
+ * Returns true if this control validated successfully.
+ * Defaults to true.
+ * @return bool wether this control validated successfully.
+ */
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ /**
+ * @param bool wether this control is valid.
+ */
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
+
/**
* Raises <b>OnTextChanged</b> event.
* This method is invoked when the value of the {@link getText Text}
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php
index 892bdc87..da6ad153 100644
--- a/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket284Component.php
@@ -2,6 +2,7 @@
class Ticket284Component extends TTemplateControl implements IValidatable
{
+ private $_isValid;
public function onPreRender($param)
{
if (!$this->ShowHours && $this->ShowMinutes)
@@ -90,5 +91,13 @@ class Ticket284Component extends TTemplateControl implements IValidatable
return $this->TimeStamp;
}
}
+ public function getIsValid()
+ {
+ return $this->_isValid;
+ }
+ public function setIsValid($value)
+ {
+ $this->_isValid=TPropertyValue::ensureBoolean($value);
+ }
}
-?> \ No newline at end of file
+?>
diff --git a/tests/FunctionalTests/tickets/tests/Ticket595TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket595TestCase.php
index e2487f25..4321bd67 100644
--- a/tests/FunctionalTests/tickets/tests/Ticket595TestCase.php
+++ b/tests/FunctionalTests/tickets/tests/Ticket595TestCase.php
@@ -18,7 +18,7 @@ class Ticket595TestCase extends SeleniumTestCase
$this->type($base.'A', 'test@pradosoft.com');
$this->click($base.'ctl2');
$this->pause(800);
- $this->assertAttribute($base.'A@class','');
+ $this->assertAttribute($base.'A@class','null');
$this->click($base.'ctl5');
@@ -33,7 +33,7 @@ class Ticket595TestCase extends SeleniumTestCase
$this->type($base.'B', 'test@pradosoft.com');
$this->click($base.'ctl5');
$this->pause(800);
- $this->assertAttribute($base.'B@class','');
+ $this->assertAttribute($base.'B@class','null');
}
}
?>