Code:
var required = '<span style="color:red; font-weight:bold;" data-qtip="Required">*</span>';
var submitForm = function() {
var myForm = Ext.getCmp('formRoles');
var data = myForm.getForm().getValues();
console.log(myForm);
console.log("data: " + Ext.JSON.encode(data));
};
Ext.define('ONC.view.administration.RolesAdd', {
extend: 'Ext.window.Window',
alias: 'widget.rolesadd',
title: 'Add Roles',
layout: 'fit',
modal: true,
autoShow: true,
width: '50%',
iconCls: 'icon-user',
initComponent: function() {
this.items = [
{
xtype: 'form',
id: 'formRoles',
padding: '5 5 0 5',
border: false,
style: 'background-color: #fff;',
fieldDefaults: {
anchor: '100%',
labelAlign: 'top',
labelWidth: 100,
labelStyle: 'font-weight: bold',
msgTarget: 'side'
},
items: [
{
xtype: 'textfield',
name: 'id',
fieldLabel: 'id',
hidden: true
}, {
xtype: 'textfield',
name: 'name',
fieldLabel: 'Name',
allowBlank: false,
afterLabelTextTpl: required
}, {
xtype: 'textareafield',
name: 'description',
fieldLabel: 'Description',
allowBlank: false,
afterLabelTextTpl: required
}
]
}
];
this.buttons = [
{
xtype: 'toolbar',
dock: 'bottom',
ui: 'footer',
items: [
'->',
{
iconCls: 'icon-save',
text: 'Save',
handler: submitForm
}, {
iconCls: 'icon-reset',
text: 'Cancel',
scope: this,
handler: this.close
}
]
}
];
this.callParent(arguments);
}
});
when i'm trying to click Save button, it's always call function submitForm without trying to running form validation before.