PDA

View Full Version : [CLOSED] Create model with rest proxy, problem dealing with id.



vincentc
11 Apr 2014, 12:30 AM
Hello,

I have problem creating a new record :


var record = Ext.create('ContentType', {name: "test"});
record.save();
The server get a POST operation, with "id" sent with value "ContentType-1". It reject this, as "id" has wrong value.


var record = Ext.create('ContentType', {id: 0, name: "test"});
record.save();
The server get a PATCH operation with url "/contenttypes/0", as the record is not set as "phantom: true". It

Are the two process invalid or is it a bug ?

Here is my model definition :

Ext.define('ContentType', {
extend: 'Ext.data.Model',


fields: [
{ name: 'name', type: 'string' }
],


proxy: {
type: 'rest',
url: '/contenttypes'
}
});

vincentc
11 Apr 2014, 12:39 AM
https://fiddle.sencha.com/?fiddle=517#fiddle/517

evant
11 Apr 2014, 1:15 AM
It sends along the id parameter so you can refer to it when you send it back from the server.

You can disable it by setting writeRecordId: false on the writer.

vincentc
16 Apr 2014, 2:03 AM
Thank you, it resolves my problem :)