PDA

View Full Version : [CLOSED] Form API with ExtDirect



steffenk
25 Mar 2010, 5:39 AM
Ext version tested:

Ext 3.2 RC


Adapter used:

ext


css used:

only default ext-all.css





Operating System:

any


Description:

When i define a component (FormPanel) and use the api property it often fails. Sorry to be unprecise, but most cases fail. Example:


TYPO3.EM.TerUpload = Ext.extend(Ext.form.FormPanel, {
border:false,
recordData: null,

initComponent:function() {



Ext.apply(this, {
itemId: 'extUploadForm',
height: 340,
defaultType: 'textfield',
api: {
load: TYPO3.EM.ExtDirect.loadUploadExtToTer,
submit: TYPO3.EM.ExtDirect.uploadExtToTer
},
paramsAsHash: false,

defaults: {width: 350},
items: [{
fieldLabel: 'Repository Username',
name: 'fe_u'
}, {
fieldLabel: 'Repository Username',
inputType: 'password',
name: 'fe_p'
}, {
fieldLabel: 'Changelog for upload',
xtype: 'textarea',
height: 150,
name: 'uploadcomment'
}, {
xtype: 'button',
text: 'Upload extension',
scope: this,
handler: function() {
this.form.submit({
waitMsg : 'Sending data...',
success: function(form, action) {
...
form.reset();
}
});
}
}],
listeners: {

activate: function(panel) {


}
},
scope: this
});

TYPO3.EM.TerUpload.superclass.initComponent.apply(this, arguments);
},

onRender: function() {


TYPO3.EM.TerUpload.superclass.onRender.apply(this, arguments);


this.form.load(); // <- fails with form.getAttributes is not a fuinction
}


});

But when i do the api definition in onRender it works


Ext.apply(this.getForm(),{
api: {
load: TYPO3.EM.ExtDirect.loadUploadExtToTer,
submit: TYPO3.EM.ExtDirect.uploadExtToTer
},
paramsAsHash: false

});

When i debug first case, the api in form is null.

Condor
25 Mar 2010, 6:31 AM
If you want to configure a class in initComponent then you not only need to apply the config object to 'this', but also to the initialConfig.

Use:

var config = {...};
Ext.apply(this, config);
Ext.apply(this.initialConfig, config);

Jamie Avins
25 Mar 2010, 8:19 AM
If you want to configure a class in initComponent then you not only need to apply the config object to 'this', but also to the initialConfig.

Use:

var config = {...};
Ext.apply(this, config);
Ext.apply(this.initialConfig, config);

Let us know if you still have the issue after applying your configuration to both.

steffenk
25 Mar 2010, 8:52 AM
sry, i don't get the advice correct. In my first code, the api is in the Ext.apply-block. All other properties are also done there and works perfect, it's only the api part that doesn't work as expected.
If i do the same without ExtDirect it works too.

And, isn't this all done with the call of the parent method with
TYPO3.EM.TerUpload.superclass.initComponent.apply(this, arguments);
?

Do i have an error in reasoning?

evant
25 Mar 2010, 8:56 AM
Look at the createForm method in FormPanel and it will all become clear.

steffenk
25 Mar 2010, 9:43 AM
Ah, now i got it :) Means, either i have to apply the api to initialConfig or apply it after initComponent, and all because createForm does the new Ext.form.BasicForm.

Ok, so the bug report can be closed, i've learned something new. Thanks for the hints!