I have made my own custon vtype which performs an ajax request to check if a username is available in the database:
Ext.apply(Ext.form.VTypes, {
username: function(val, field) {
var conn = new Ext.data.Connection();
conn.request({
url: '/account/CheckUsernameAvailability',
params: { "username": val },
success: function(data) {
console.log("field = ", field);
console.log(data.responseText);
},
failure: function() {
Ext.Msg.alert('Status', 'Unable to add vote');
}
});
},
usernameText: 'Username is already taken'
});
The problem is that the request is obviously asynchronous so I cant just return true if the data.responseText is OK. Within this function I need to be able to set "field" to be valid.
But I cant seem to find anything in the Ext API that shows how to do this? (i guess i must be missing something)