View Full Version : [DEFER] Field original values lost if values set before render.

21 Jul 2010, 3:29 AM
I have a form in an Ext.Window.
I have set value to '' in the config object for all fields.

The form gets used in two situations (adding and editing).
When editing, values are added into the form using Ext.form.BasicForm.setValues(), and then the window is displayed.
When adding, the form is reset using Ext.form.BasicForm.reset(), and then the window is displayed.

If the first thing done is an edit, then the values that were set with setValues() overwrite the originalValue property of each field! This means that on later adds, the form is filled with the values from that original edit.

This is caused because when the field is rendered, Field.initValue() sets the originalValue property from the field's value.

This problem can be worked around either by always setting values instead of resetting the form, or by showing the window before setting values into it.

I think that either originalValue should be set in the constructor, or it should be remembered separately from value, so that initValue() can use the correct originalValue, or this situation should be clearly documented in the API docs.

Jamie Avins
21 Jul 2010, 9:25 AM
This is a limitation currently as the forms use the dom for storage currently. This is being changed in 4.x to be within the component by default.