View Full Version : [FIXED] Wrong method selected when saving a record with id = null.

3 Nov 2011, 12:01 PM
ExtJS v. 4.07
Firefox, IE, Chrome on windows 7

It may be a bug or just a confusion for a new user.

When a model instance (record) is created without setting an id on it, and its save() method is called, the request is send to the server as POST (Create).

If, for any reason , an id is set first on the record (on client side only) and then nullified before saving it (record.set ({id: null}), the save method send it as PUT request (update).

In both cases the record id is null and, in my opinion, should be treated the same way.

see more at:

4 Nov 2011, 5:15 AM
Have you tried setting it as undefined instead of null?

4 Nov 2011, 5:53 AM
I did not but I tried it now. It is still the same problem as with null, the request is sent as PUT.

There is a way to workaround this problem, as discussed in the thread i referred to, setting the phantom flag

myRecord.set({id: null});
myRecord.phantom = true;

However, it is still quite misleading and, in my opinion, should be fixed.
If there is no need to set the phantom flag when a record is created without an id, there should not be such a need when the id is first set and then reset to null or undefined.

4 Nov 2011, 5:58 AM
Yeah, when you add a new record to a store, the phantom property should be set to true even if you mess with the id. The Writer should be the one who changes it.