PDA

View Full Version : Ext.ModelManager.create adds empty id field



fortunado
13 Sep 2011, 9:56 AM
Hi,
I'm trying to use Ext.data.Model + Rest proxy.
My code:


Ext.define('ExCategory', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{ name: 'id', type: 'int'},
{ name: 'name', type: 'string' }
],
proxy: {
type:'rest',
url:'/api/ex_categories'
}
});


var ExCtg = Ext.ModelManager.getModel('ExerciseCategory');
var ctg12 = Ext.ModelManager.create({name: 'category12'}, 'ExCategory');
ctg12.save();


Manual says:

"Calling save (http://docs.sencha.com/ext-js/4-0/#%21/api/Ext.data.Model-method-save) on the new Model instance tells the configured RestProxy that we wish to persist this Model's data onto our server. RestProxy figures out that this Model hasn't been saved before because it doesn't have an id, and performs the appropriate action - in this case issuing a POST request to the url we configured (/users)."

but when I create new model instance, and call .save(), firebug shows me the empty id field in post data:
{"id":0,"name":"category12"}

I suppose model instance must send everything execept non-initialized id field,
and retrive one from the server post reply

Did I miss somethong, or this is a bug ?
Thanks.