Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1667 in a recent build.
  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default The setFields property of Ext.data.Model does not seem to work.

    My expectation is that model.setFields can be used with form.getValues. Here's the code I used to verify this is not working as expected.

    Code:
            var values = myForm.getValues();
            ...
            if (model && model.isModel) {
                // The following does not work as expected
                //model.setFields(values);
                // The following does what I thought setFields would do if working correctly
                for (var field in values) {
                    model.set(field, values[field]);
                }
                model.save();
                console.log("model", model);
            }
            ...
    If this is not the expected behavior for setFields, then please update the documentation to clarify how setFields should work.

    Thanks

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    18
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default

    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default

    setFields is meant to set new field definitions for the model, not update the values. I will update the documentation to explain this.

    record.set(values) should do what you want.

  4. #4
    Sencha User edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Vote Rating
    9
    edspencer is a jewel in the rough edspencer is a jewel in the rough edspencer is a jewel in the rough

      0  

    Default

    I've added some better docs for this now
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

  5. #5
    Sencha User
    Join Date
    Apr 2011
    Posts
    212
    Vote Rating
    3
    bweiler is on a distinguished road

      0  

    Default

    Thanks! This makes sense now.