PDA

View Full Version : Field isDirty function change



bclinton
30 Dec 2011, 2:36 PM
I see that the isDirty() function in Ext.form.field.Field has been changed in the 4.1 preview release.

This is the function in 4.07:

isDirty : function() {
var me = this;
return !me.disabled && !me.isEqual(me.getValue(), me.originalValue);
},

In the 4.1 PR1, the function disregards changes in fields with an undefined originalValue:

isDirty : function() {
var me = this;
return !me.disabled && typeof me.originalValue != 'undefined' && !me.isEqual(me.getValue(), me.originalValue);
},


Is there a reason for this change and can we expect it to remain this way in the future?

This change broke some of my code, but in a way that exposed another bug in my code related to the issue where the trackResetOnLoad config option doesn't get passed from the FormPanel to the Ext.form.Basic when specified in the config or initialConfig as discussed in this thread:

http://www.sencha.com/forum/showthread.php?144109-Recommended-way-to-configure-form.Basic-from-form.Panel-in-Ext-4-with-Ext.define
(http://www.sencha.com/forum/showthread.php?144109-Recommended-way-to-configure-form.Basic-from-form.Panel-in-Ext-4-with-Ext.define&highlight=trackresetonload)
Both of these issues seem like they might create confusion for users:

In the first, a field won't show as dirty if it hasn't been initialized with a value. It seems to me that a field that has had its value changed from undefined to something else should be considered a dirty field.

The second issue, that trackResetOnLoad configs don't get passed to the basic form when extending FormPanel, might increase the confusion because when loads are not tracked, all fields in a form have an originalValue of undefined.

mitchellsimoens
31 Dec 2011, 9:07 AM
Just looking at the code it looks like the dirty status was incorrect when the field was instantiated and checked for dirty status. Anything can change but without a bug report it likely will not change.

bclinton
1 Jan 2012, 6:50 PM
I originally posted here because I wasn't sure if it was a bug or if it is the intended behavior.

Just in case, I posted a bug report and a test case here: http://www.sencha.com/forum/showthread.php?170055-4.1-Form-Field-isDirty()-shows-false-if-field-has-no-original-value&p=705892#post705892