Alex, TL;DR, here is the bug fix for 4.0.7:
Code:
Ext.override(Ext.form.field.Radio, {
resetOriginalValue: function () {
//Override the original method in Ext.form.field.Field:
//this.originalValue = this.getValue();
//this.checkDirty();
this.getManager().getByName(this.name).each(function (item) {
item.originalValue = item.getValue();
item.checkDirty();
});
}
});
For those interested, the way to track down this bug is to start with the source for Ext.form.Basic, setValues method. Inside the setValues method there is a helper function setVal that looks like this:
Code:
function setVal(fieldId, val) {
var field = me.findField(fieldId);
if (field) {
field.setValue(val);
if (me.trackResetOnLoad) {
field.resetOriginalValue();
}
}
}
You can see it calls setValue on the first field that it finds by given fieldId (field name), then resetOriginalValue. Let's take a look at setValue in Ext.form.field.Radio:
Code:
setValue: function(v) {
var me = this,
active;
if (Ext.isBoolean(v)) {
me.callParent(arguments);
} else {
active = me.getManager().getWithValue(me.name, v).getAt(0);
if (active) {
active.setValue(true);
}
}
return me;
}
This specialized setValue method takes into account that there are multiple radios with the same name, and that setValue is called on just one of them (the first one found by calling findField in basic form's setValues. So, setValue for radio field has been made "smart". Now, what about resetOriginalValue for the radio field? A specialized resetOriginalValue for radio fields was never implemented - it is simply inherited from the default in Ext.form.field.Field, which looks like this:
Code:
resetOriginalValue: function() {
this.originalValue = this.getValue();
this.checkDirty();
}
The fix then is to make resetOriginalValue as "smart" as setValue, i.e. take into account that there are multiple radio fields in the same group, with the same name.