I have problems with a form saving to a store. The form loads a record for editing a existing record, or is blank for a new record. Editing a existing record works fine. Creating a new one works fine as well. I get problems if I want to edit & update a newly created record without closing and re-opening the form.
I guess the problem is that the id of the record inside the store is assigned through the remote server. The form is holding a copy of the model and is not taking any notice of the changing id.
Any ideas how to keep the form and the store in sync?
The following code is used for saving:
var basicForm = this.up('form').getForm(),
record = basicForm.getRecord();
if (basicForm.isValid()) {
if (!record) {
record = Ext.data.StoreManager.lookup('theModel').add( this.up('form').getForm().getFieldValues())[0];
basicForm.loadRecord(record);
} else {
basicForm.updateRecord(record);
}
}