PDA

View Full Version : Define a form with trackResetOnLoad = true is ignored



lucasguaru
24 Oct 2011, 10:30 AM
If you create a form with trackResetOnLoad = true on the config, it works fine.
If you define your own form with trackResetOnLoad = true, it's ignored.
It is happening because the method which creates the basicForm uses the initialConfig.
I'm not sure but I guess that initialConfig is the config you use as parameter to create the object.
Is that a bug or they have another way to do this?

bt_bruno
25 Oct 2011, 1:50 AM
Yes, you're right. BasicForm is created using FormPanel's initialConfig. But you can do something like this:


Ext.define('App.view.client.Form', {
extend: 'Ext.form.Panel',

constructor: function(cfg) {
cfg = cfg||{};
cfg.trackResetOnLoad = true;
this.callParent(arguments);
},

// ...
});

You also can wait to BasicForm be created, and then change the value dynamically, it's just a flag anyway:


initComponent: function() {
// ...
this.callParent(arguments);
this.form.trackResetOnLoad = true;
}

I don't know if it is quite a bug, you could question that into bugs forum section and find out.

lucasguaru
25 Oct 2011, 3:09 AM
Thanks Bruno.
Doing it on the constructor will sove my problem too.
I posted this on the Bug Forum too.

Phil Guerrant
23 Nov 2011, 2:07 PM
Bruno, I'd recommend using Ext.applyIf() to apply the default values to the config object in your constructor. This will allow the defaults to be overridden when the form panel is instantiated. See http://www.sencha.com/forum/showthread.php?152183