View Full Version : Blank Ext.form.Checkbox causes isDirty() to return true

27 May 2009, 3:12 PM
Hi all,

Here's the problem I'm having. I've created a FormPanel. The form fields are all blank and the form does not load its default values via Ajax so I don't think the trackResetOnLoad flag applies. When calling the isDirty() method of the BasicForm, the checkbox always returns true.

I think I know why this is happening but I'm not sure of the reason behind it. The Ext.form.Checkbox code sets its initial value to Ext.emptyFn. This means the Fields originalValue variable is undefined. So when the isDirty() method is called on a checkbox, it compares the checked value against "undefined" and the comparison will always fail.

Here's the code from Ext.form.Checkbox.js (lines 118 - 130):

// private
initValue : Ext.emptyFn,

* Returns the checked state of the checkbox.
* @return {Boolean} True if checked, else false
getValue : function(){
return this.el.dom.checked;
return false;

and here's the isDirty() code from Ext.form.Field.js (lines 261 - 266):

isDirty : function() {
if(this.disabled) {
return false;
return String(this.getValue()) !== String(this.originalValue);

The problem this is causing for me is when the FormPanel is closed I want to prevent that by checking the isDirty() and have the person either clear the form or complete the form first. But the checkbox is causing isDirty() to always return true. Is there some sort of work around for this? Any help would be greatly appreciated.

12 Jun 2009, 3:14 AM
+1. Same problem here with 3.0 RC2