Results 1 to 5 of 5

Thread: Model save() method not dealing with mappings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Jul 2012
    Location
    Italy
    Posts
    84
    Answers
    1
    Vote Rating
    4
      0  

    Default Model save() method not dealing with mappings

    Hello,
    I'm working with a model that use a mapping, and I'm seeing a different behavior with GET and POST, with POST not getting all data.

    Here's the simplified version of my model:
    Code:
    Ext.define('MyMessage', {
        extend: 'Ext.data.Model',
        config: {
            fields: [
                { name: 'id', type: 'int' },
                { name: 'title', type: 'string' },
                { name: 'body', type: 'string' },
            ],
            associations: [
                { type: 'belongsTo', model: 'MyUser', foreignKey: 'author.id' },
            ]
        }
    });
    When calling MyMessage.load(<id>), the "author.id" field works fine.
    But then if I call:
    Code:
    var newMsg = Ext.create('MyMessage', {
        title: 'MyTitle',
        body: 'MyBody'
    });
    
    
    newMsg.save();
    The record is saved, the local client data is updated except for the "author.id" association, which is undefined. Even tough the data returned from the server has the "author" object inside.

    Is that normal?
    Last edited by Tegola; 20 Dec 2012 at 3:52 AM. Reason: Spelling

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •