PDA

View Full Version : [FIXED] 4.2.2: modifying model instance field can change defaultValue



alicexyl
23 Oct 2013, 11:57 AM
Ext version tested:

Ext 4.2.2
Browser versions tested against:

irrelevant
DOCTYPE tested against:

irrelevant
Description:

When model field defaultValue is an array, then modifying a model instance's field value will change the defaultValue array too.
Steps to reproduce the problem:

Create model w a field whose defaultValue is an array
Create a model instance
Get the array field value and modify it, e.g. add an item
Create another model instance
Get the array field value for 2nd model instance
The result that was expected:

2nd model instance array field value should be equal to original defaultValue
The result that occurs instead:

2nd model instance array field value is equal to 1st model instance array field value
Please see fiddle: https://fiddle.sencha.com/#fiddle/14j

S (https://fiddle.sencha.com/#fiddle/14j)uggested solution:
In Ext.data.Model constructor(), replace lines like these:


value = field.defaultValue;

with:


value = Ext.clone(field.defaultValue);

We patched Model with override this way.

Gary Schlosberg
23 Oct 2013, 3:43 PM
Thanks for the report! I have opened a bug in our bug tracker.