Hi,
In my model I've set up
PHP Code:
Ext.define('SA.model.User', {
extend: 'Ext.data.Model',
fields: ['id','uname', 'email'],
validations: [{
type: 'length',
field: 'uname',
min: 1
}, {
type: 'length',
field: 'email',
min: 1
}]
});
so in my controller I've to check if data is valid
how I can get the form from my controller
PHP Code:
Ext.define('SA.controller.Users', {
extend: 'Ext.app.Controller',
models: ['User'],
stores: [
'Users'
],
views: [
'user.List',
'user.Edit',
'user.Insert'
],
init: function() {
this.control({
'userlist': {
itemdblclick: this.editUser,
itemclick: this.enableDeleteButton
},
'userlist > toolbar > button#btnAdd': {
click: this.showInsertUser
},
'userinsert button[action=save]': {
click: this.insertUser
},
'useredit button[action=save]': {
click: this.updateUser
}
});
},
insertUser: function(button) {
console.dir(this.getUserInsertView());
// var win = button.up('window'),
//form = win.down('form');
//THIS DOESN'T WORK of course :)
//if (form.isValid()) {
//win.close();
//alert('oii');
}
});
My view
PHP Code:
Ext.define('SA.view.user.Insert', {
extend: 'Ext.window.Window',
alias : 'widget.userinsert',
title : 'Insert User',
layout: 'fit',
autoShow: true,
initComponent: function() {
this.items = [
{
xtype: 'form',
items: [
{
xtype: 'textfield',
name : 'uname',
fieldLabel: 'Name'
},
{
xtype: 'textfield',
name : 'email',
fieldLabel: 'Email'
}
]
}
];
this.buttons = [
{
text: 'Save',
action: 'save'
},
{
text: 'Cancel',
scope: this,
handler: this.close
}
];
this.callParent(arguments);
}
});