1. #1
    Sencha User
    Join Date
    Aug 2007
    Posts
    100
    Vote Rating
    0
    michiel is on a distinguished road

      0  

    Default Can't submit my form (win.getForm() is not a function)

    Can't submit my form (win.getForm() is not a function)


    Hi there,

    I'm a bit puzzled here. I've created a form in a window, but when I try to submit it, similar to how I submit other forms I receive an error message that win.getForm() is not a function. What am I doing wrong here? I provided the source below.

    Can anyone point me to a resource that explains what I'm doing wrong here?

    Thanks in advance!

    Michie

    Code:
    	function newSection() {
     	  
    		win = new Ext.Window({
    			width:500,
    			id:'new-win',
    			height:280,
    			autoScroll:true,
    			bodyStyle: 'background: #fff',
    			modal: true,
    			items:[{
    				layout:'form',
    				labelWidth: 150,
    				bodyStyle: 'margin: 20px; margin-top: 40px;',
    				border: false,
    				buttonAlign:'center',
    				items: [{
    					xtype: 'textfield',
    					fieldLabel: 'Foo'
    				},{
    					xtype: 'textfield',
    					fieldLabel: 'Foo 2'
    				}],
    				buttons:[{
    					text: 'Save',
    					handler: function() {
    						
    						win.getForm().submit({
    							url: 'save.php',
    							scope:this,
    							success: function(form, msg) {
    								Ext.Msg.alert('Success', msg.result.error);
    							},
    							failure: function(form, msg) {
    								Ext.Msg.alert('Error', msg.result.error);
    							},
    							waitMsg:'Saving...'
    						});			
    					}
    				},{
    					text: 'Cancel',
    					handler: function() {
    						win.close();
    					}					
    				}] 
    			}],						
    			title:'Test'
    		});
    		win.show();
    	}

  2. #2
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    186
    Vote Rating
    0
    Darklight is on a distinguished road

      0  

    Default


    a Window Component doesn't have a getForm() method...

  3. #3
    Sencha User
    Join Date
    Aug 2007
    Posts
    100
    Vote Rating
    0
    michiel is on a distinguished road

      0  

    Default


    Ah ok .. I see .. then what would be the solution to submit the form inside the window?

  4. #4
    Ext JS Premium Member
    Join Date
    Apr 2007
    Posts
    186
    Vote Rating
    0
    Darklight is on a distinguished road

      0  

    Default


    right now you don't actually have a form, just a FormLayout. so change
    layout:'form',
    to
    xtype:'form',
    id:'YourFormID'
    and then change the button handler to
    Ext.getCmp('YourFormID').getForm().submit(

  5. #5
    Sencha User
    Join Date
    Aug 2007
    Posts
    100
    Vote Rating
    0
    michiel is on a distinguished road

      0  

    Default


    Perfect! Thanks for the swift reply. I think I'll look more into the differences between layout and xtype now then .. because I think I don't really understand that part fully!

    Thanks!

Thread Participants: 1