Search code examples
postlaravel-4extjs4

extjs 4.2 POST data id=0 generates method not allowed - laravel 4


When I send data ( store in codeblock ) to my laravel 4 server I get "method not allowed" and the server returns all methods allowed except POST. When I comment out 'id' in my model, everything works. ( don't want to comment out id)

I tried the writeRecordId:false and writeAllFields:false in my writer property but this doesn't remove the id while sending..

Ext.define('Equipment.store.Equipments', {
extend: 'Ext.data.Store',
model: 'Equipment.model.Equipment',
requires: ['Ext.data.proxy.Rest'],
alias: 'store.Equipments',
proxy: {
    type: 'rest',
    url: '/json/stock/equipment',
    reader: {
        type: 'json',
        root: 'data',
        successProperty: 'success'
    },
    writer: {
        type: 'json'
    }
},
groupField: 'location'

});

data send:

{"id":0, "location":"Building123","locationDetails":"office 2","locationIndex":"drawre 5", "description":"item 7"}

Solution

  • I guess I've sorta solved it I think:

    Ext.define('Equipment.model.Equipment', {
    extend: 'Ext.data.Model',
    
    fields: [
    
        {   name: 'id',
            type: 'number',
            useNull: true
        },
    

    Placing 'useNull: true' along id sets {"id":null, ... in the data which is accepted by the server. Anyone care to comment?