diff options
4 files changed, 33 insertions, 62 deletions
@@ -22,6 +22,7 @@ BUG: TCaptcha: publish images with image/png content-type (ctrlaltca) BUG: Issue #35 - [840] Capital letters for the initial letter of the directories name (ctrlaltca) BUG: Issue #66 - TButton.CausesValidation=False ignored when pressing Enter on the button within a control with DefaultButton (ctrlaltca) NEW: Issue #83 - PHP configuration style (Carl) +BUG: Issue #91 - TActiveCustomValidator can not be updated in JavaScript callback (ctrlaltca) ENH: Issue #106 - TJavaScript::jsonEncode and TJavaScript::jsonDecode should use built-in PHP functions (ctrlaltca) ENH: Issue #173 - Add "dragdropextra" (supergsting) patch, mouse coordinates and key status to drag & drop controls (Christophe, DevWorx) BUG: Issue #179 - Serialization issues in Prado (ctrlaltca) diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page index e71e60c8..8ef69a9a 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/TActiveCustomValidator/Home.page @@ -12,7 +12,7 @@ Custom validator using callbacks: ControlToValidate="textbox1"
ErrorMessage="Please enter 'Prado'"
OnServerValidate="validator1_onvalidate" />
-<com:TButton ID="button1" Text="Submit!" />
+<com:TActiveButton ID="button1" Text="Submit!" />
</td></tr>
</table>
diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js index bbf3929a..f9f42232 100644 --- a/framework/Web/Javascripts/source/prado/validator/validation3.js +++ b/framework/Web/Javascripts/source/prado/validator/validation3.js @@ -212,6 +212,20 @@ Object.extend(Prado.Validation, }
});
});
+ },
+
+ updateActiveCustomValidator : function(validatorID, isValid)
+ {
+ $H(Prado.Validation.managers).each(function(manager)
+ {
+ manager[1].validators.each(function(validator)
+ {
+ if(validator.options.ID == validatorID)
+ {
+ validator.updateIsValid(isValid);
+ }
+ });
+ });
}
});
@@ -1506,17 +1520,6 @@ Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
/**
- * Value to validate
- * @var {string} validatingValue
- */
- validatingValue : null,
- /**
- * DOM element that triggered validation
- * @var {element} invoker
- */
- invoker : null,
-
- /**
* Override the parent implementation to store the invoker, in order to
* re-validate after the callback has returned
* Calls evaluateIsValid() function to set the value of isValid property.
@@ -1545,18 +1548,7 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, this.options.OnValidate(this, invoker);
}
- if(this.enabled && !this.control.getAttribute('disabled'))
- this.isValid = this.evaluateIsValid();
- else
- this.isValid = true;
-
- // Only update the message if the callback has already return !
- if (!this.requestDispatched)
- this.updateValidationDisplay(invoker);
-
- this.observeChanges(this.control);
-
- return this.isValid;
+ return true;
},
/**
@@ -1566,21 +1558,6 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, */
evaluateIsValid : function()
{
- var value = this.getValidationValue();
- if(!this.requestDispatched && (""+value) != (""+this.validatingValue))
- {
- this.validatingValue = value;
- var request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
- if(this.options.DateFormat && value instanceof Date) //change date to string with formatting.
- value = value.SimpleFormat(this.options.DateFormat);
- request.setCallbackParameter(value);
- request.setCausesValidation(false);
- request.options.onSuccess = this.callbackOnSuccess.bind(this);
- request.options.onFailure = this.callbackOnFailure.bind(this);
- request.dispatch();
- this.requestDispatched = true;
- return false;
- }
return this.isValid;
},
@@ -1590,36 +1567,15 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, * @param {CallbackRequest} request - CallbackRequest.
* @param {string} data - Response data.
*/
- callbackOnSuccess : function(request, data)
+ updateIsValid : function(data)
{
this.isValid = data;
this.requestDispatched = false;
if(typeof(this.options.onSuccess) == "function")
- this.options.onSuccess(request,data);
+ this.options.onSuccess(null,data);
this.updateValidationDisplay();
this.manager.updateSummary(this.group);
- // Redispatch initial request if any
- if(this.isValid) {
- if(this.invoker instanceof Prado.CallbackRequest) {
- this.invoker.dispatch();
- } else {
- this.invoker.click();
- }
- }
},
-
- /**
- * Handle callback failure.
- * @function ?
- * @param {CallbackRequest} request - CallbackRequest.
- * @param {string} data - Response data.
- */
- callbackOnFailure : function(request, data)
- {
- this.requestDispatched = false;
- if(typeof(this.options.onFailure) == "function")
- this.options.onFailure(request,data);
- }
});
/**
diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php index 80d2f522..e0884c55 100644 --- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php +++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php @@ -102,6 +102,20 @@ class TActiveCustomValidator extends TCustomValidator }
/**
+ * @param boolean whether the value is valid; this method will trigger a clientside update if needed
+ */
+ public function setIsValid($value)
+ {
+ parent::setIsValid($value);
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $client = $this->getPage()->getCallbackClient();
+ $func = 'Prado.Validation.updateActiveCustomValidator';
+ $client->callClientFunction($func, array($this, $value));
+ }
+ }
+
+ /**
* This method is invoked when a callback is requested. The method raises
* 'OnCallback' event to fire up the event handlers. If you override this
* method, be sure to call the parent implementation so that the event
|