I have created a custom vtype that I want to reuse, the vtype will be used to confirm data in the textfield matches another textfield, i.e. confirm email address, etc.
The vtype works perfectly except I need a custom error validation message for each of my textfields, currently I am stuck with the default message in the vtype.
I played around and I am able to pass a field called failedValidationTextField from my view to the vtype, question is how do I get this to be the default message returned back from the vtype?
//vtype
confirmTextFieldValidation: function(val, field) {
console.log(field.failedValidationTextField); //the data is getting passed into the vtype
if (field.initialTextField) {
var txtField = field.up('panel').down('#' + field.initialTextField);
return (val === txtField.getValue());
}else{
return false;
}
}, 'confirmTextFieldValidationText': 'This is the message that is currently getting returned'
//view
{
xtype: 'textfield',
itemId: 'textfield#1',
msgTarget: 'side',
vtype: 'confirmTextFieldValidation',
failedValidationTextField: 'This is the message I want passed back when validation fails',
].'
Try using vtypeText
confirmTextFieldValidation: function(val, field) {
console.log(field.failedValidationTextField); //the data is getting passed into the vtype
if (field.initialTextField) {
var txtField = field.up('panel').down('#' + field.initialTextField);
//Validation failed message
field.vtypeText = field.failedValidationTextField;
return (val === txtField.getValue());
}else{
return false;
}