Results 1 to 3 of 3

Thread: Problem trying to setup my first extended FormPanel class.

  1. #1

    Default Problem trying to setup my first extended FormPanel class.

    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

    Code:
    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);

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Location
    Bah
    Posts
    434

    Default

    Code:
    				buttons: [
    				  {
    					text: 'Save',
    					handler: function() {
    						this.getForm().submit();
    					},
                                            scope: this
    				  }
    				]
    Fernando G

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Try
    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •