yiisoft/yii2 — pull request #4485 by Alex-Code (2014-07-28 09:11:04+00:00)
Title: Deferred validation

Added support of deferred validation in ```ActiveForm```

The ```validate``` option in ```ActiveField``` ```getClientOptions``` now has a forth parameter, ```deferred```.
This is an array which ```Deferred``` objects can be pushed into.

e.g.
An inline validator can do something like
```
['attribute', 'method', 'clientValidate' => function() {
return 'deferred.push($.ajax("/check").done(function(data) { messages.push(data); }));';
}],
```

An image could be checked client side.
```
var def = $.Deferred();
var img = new Image();
img.onload = function() {
if (this.width > 150) {
messages.push('Image too wide!!');
}
def.resolve();
}
var reader = new FileReader();
reader.onloadend = function() {
img.src = reader.result;
}
reader.readAsDataURL(file);

deferred.push(def);
```

Thoughts?