I would like to get my values from my form through the getRecord() function. This is the result im currently getting from form.getRecord():
The data object is empty.
This is my controller:
onAddNewsClick: function(button, e, eOpts) {
var win = this.getNewsEdit();
if(!win){
win = Ext.create('widget.newsedit');
}
this.getNewsPanel().loadRecord(Ext.create('model.news'));
console.log(this.getNewsPanel());
this.adding = true;
win.show();
},
OnSaveNewsClick: function(button, e, eOpts) {
var form = this.getNewsPanel();
console.log(form);
var selectedRecord = form.getRecord();
console.log(selectedRecord);
if (this.adding) {
this.adding = undefined;
}
}
The correspoding Model:
Ext.define('mobile_admin.model.News', {
extend: 'Ext.data.Model',
alias: 'model.news',
requires: [
'Ext.data.field.Field'
],
fields: [
{
name: 'title'
},
{
name: 'newscontent'
},
{
name: 'newsdate'
},
{
name: 'status'
}
]});
With form.getValues() I get all the values of the form.
It feels like that the model is not connecting to the form. In the form I put the necessary name connection: (http://docs.sencha.com/extjs/5.1.0/Ext.form.Basic.html#method-loadRecord)
My Form items:
items: [
{
xtype: 'textfield',
fieldLabel: 'Titel',
name: 'title'
},
{
xtype: 'datefield',
fieldLabel: 'Datum',
name: 'newsdate'
},
{
xtype: 'htmleditor',
height: 150,
width: 600,
fieldLabel: 'Inhalt',
name: 'newscontent',
},
{
xtype: 'textfield',
fieldLabel: 'Status',
name: 'status'
},
]
Anyone has an idea? I use ExtJs (5.1.3).
//EDIT: I found out that I can set the record like this:
var b = form.getRecord()
b.set(form.getValues()
Shouln't this ExtJs do automatically?