Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ext.form.Basic how to reset fields when trackResetOnLoad true?

I got a Ext.form.Basic with the trackResetOnLoad:true config.

When I call reset() on a field it gets its values from the form setValues() method.
How do I reset my fields now?
When I just do field.setValue('') the form marks it as invalid because the field is required.

Thanks in advance.

like image 647
A1rPun Avatar asked Jan 31 '13 10:01

A1rPun


1 Answers

You have to manually reset all of the originValues of all fields (and some other)

This snipped will do this

var items = form.getForm().getFields().items,
    i = 0,
    len = items.length;
for(; i < len; i++) {
    var c = items[i];
    c.value = '';
    if(c.mixins && c.mixins.field && typeof c.mixins.field['initValue'] == 'function'){
        c.mixins.field.initValue.apply(c);
        c.wasDirty = false;
    }
}

working example

like image 148
sra Avatar answered Oct 21 '22 10:10

sra