PDA

View Full Version : Problem trying to setup my first extended FormPanel class.



tdondich
22 Nov 2007, 2:01 PM
I'm trying to extend FormPanel to be a reusable component. The code below results in an error:

this.getForm is not a function

Can someone explain to me what scope I am running in when defining the buttons attribute? I was assuming that I was running in the scope of the newly created object (the first param to superclass.constructor.call. Is this the incorrect way of setting up an extended FormPanel? :) Thanks for any assistance. I think we need more examples in the API documentation to show best practices.

Thanks in advance!

Taylor


test.myform = function(id) {
var myID = id;

test.myform.superclass.constructor.call(this, {
items: [
new Ext.form.TextField({
fieldLabel: 'Name',
name: 'name',
width: 250
}),
new Ext.form.TextArea({
name: 'description',
fieldLabel: 'Description',
width: 250
})

],
border: false,
buttonAlign: "left",
buttons: [
{
text: 'Save',
handler: function() {
this.getForm().submit();
}
}
]
});
}

Ext.extend(test.myform, Ext.form.FormPanel);

efege
22 Nov 2007, 2:15 PM
buttons: [
{
text: 'Save',
handler: function() {
this.getForm().submit();
},
scope: this
}
]

tryanDLS
22 Nov 2007, 2:28 PM
Try


handler: function() {
this.getForm().submit();
},
scope:this


Best practice for extending the classes would be to follow how Ext actually does in the Component hierarchy - Component->BoxComponent->...FormPanel