PDA

View Full Version : User-defined validation doesn't bind button



talha06
5 Sep 2012, 11:34 PM
Hi everyone,

I defined a validation which controls if the id is unique or not to bind a button. It works well with built-in validations well, but it doesn't bind for my own validation.

Here's what I've tried:

View - FormPanel:


Ext.define(appName + '.view.user.UserForm', {
extend: 'Ext.form.Panel',
requires: [appName + '.view.language.LanguageCombo'],
alias: 'widget.userform',
// title : 'User Form',
iconCls: 'icon-form',
frame: true,
padding: '5 5 0 5',
border: true,
buttonAlign: 'right',
width: '100%',
// height : 200,
monitorValid: true,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'left',
labelWidth: 110,
anchor: '98%',
allowBlank: false,
selectOnFocus: true,
msgTarget: 'side'
},
initComponent: function () {
var me = this;


this.title = bundle.getMsg('userform.title');


this.items = [{
xtype: 'numberfield',
minValue: 1,
fieldLabel: bundle.getMsg('userform.field.recordId'),
name: 'recordId',
itemId: 'recordId'
}, {
];


this.btnReset = Ext.create('Ext.ux.button.ResetButton', {
handler: function (btn) {
me.getForm().reset();
}
});


this.btnSubmit = Ext.create('Ext.ux.button.SaveButton', {
disabled: true,
formBind: true
});


this.buttons = [me.btnReset, me.btnSubmit];


this.callParent(arguments);
}
});

Controller Method:


var form = this.getUserForm();
if (field.getValue() && field.getValue() != '') {
Ext.Ajax.request({
url: 'user/chkRecordIdUnique.ajax',
method: 'POST',
params: {
recordId: field.getValue()
},
success: function (response, options) {
var res = Ext.decode(response.responseText);
if (!res.success) {
field.markInvalid(bundle.getMsg('record.taken'));
form.getForm().markInvalid(bundle.getMsg('record.taken'));
}
}
});
}

mitchellsimoens
17 Sep 2012, 6:55 AM
You mean where you did the markInvalid?

talha06
17 Sep 2012, 7:37 AM
You mean where you did the markInvalid?
In controller, I added a blur event handler on the field that named "recordId" in the form. The method implementation is above. Even I mark the field as invalid (also I tried marking form as invalid too), it never binds the formBind:true button which is named btnSubmit.