PDA

View Full Version : getFieldValues fix?



ethraza
7 Oct 2010, 10:37 AM
I think Sencha did a good thing when added the function getFieldValues to the BasicForm because some times we just need the field values to be gathered by the getValue function that will probably do extra processing to the value.
But I think an extra options is missing to that function so here is my 2 cents. This way the getFieldValues still behave the same way it already do, but give you the option to just get the fields that don't have the submitValue option set to false.



Ext.form.BasicForm.prototype.getFieldValues = function(dirtyOnly, submitValueOnly){
var o = {},
n,
key,
val;
this.items.each(function(f) {
if ((submitValueOnly !== true || f.submitValue !== false) && dirtyOnly !== true || f.isDirty()) {
n = f.getName();
key = o[n];
val = f.getValue();

if(Ext.isDefined(key)){
if(Ext.isArray(key)){
o[n].push(val);
}else{
o[n] = [key, val];
}
}else{
o[n] = val;
}
}
});
return o;
}
Now a wish... :)
Wold be great to have a option in the forms to use getFieldValues instead of serialization when submit action is called!