I have a model with an id property. This is the important part of the declaration.
Ext.define('E.model.portfolio.Portfolio', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' },
{ name: 'currencyId', type: 'int' },
{ name: 'startingCapital', type: 'float' },
{ name: 'startDate', type: 'date' },
{ name: 'endDate', type: 'date' },
{ name: 'isPrivate', type: 'boolean', defaultValue: true },
{ name: 'isPercentageAllocation', type: 'boolean', defaultValue: true },
{ name: 'currentAllocationPeriod', type: 'int', useNull: true },
{ name: 'frequency', type: 'int' },
{ name: 'rebalance', type: 'int' }
],
proxy: {
type: 'ajax',
url: '/someapi/action'
},
validations: [
{ type: 'presence', field: 'id' },
{ type: 'presence', field: 'name' },
{ type: 'presence', field: 'currencyId' },
{ type: 'presence', field: 'startingCapital' },
{ type: 'presence', field: 'startPeriod' },
{ type: 'presence', field: 'endPeriod' }
],
}
However when I send this model to the server it's always missing the id property. Here is the JSON that is sent up.
{
"name": "Unique Name Test",
"currencyId": 1,
"startingCapital": 1000000,
"startDate": null,
"endDate": null,
"isPrivate": false,
"isPercentageAllocation": true,
"currentAllocationPeriod": 201003,
"frequency": 2,
"rebalance": 0
}
As you can see all properties are there except ID. Does anyone have any insight as to what excatly is happening here ?