1. #1
    Ext User
    Join Date
    Feb 2008
    Posts
    3
    Vote Rating
    0
    Merovingian is on a distinguished road

      0  

    Default Form.standardSubmit Help

    Form.standardSubmit Help


    Hello all,

    This ExtJS seems to be rather good, but I am having trouble with the simplest thing. How embarrassing. :-)

    I'm a seasoned PHP developer, know the basics of JavaScript, which is fine, and I'm trying to learn ExtJS.

    I'm trying to get the example described here in the manual to work, but when I click the "Save" button in the form, the page does nothing.

    Here is my index.php file:

    Code:
    <html>
    	<head>
    		<title>ExtJS Form Test</title>
    		<link rel="stylesheet" type="text/css" href="../extjs/resources/css/ext-all.css" />
    		<script type="text/javascript" src="../extjs/adapter/ext/ext-base.js"></script>
    		<script type="text/javascript" src="../extjs/ext-all.js"></script>
    		<script type="text/javascript" src="guts.js"></script>
    	</head>
    	<body>
    		<h1>This is a Test</h1>
    		<div id="myform"></div>
    	</body>
    </html>
    Here is my form processing PHP file:

    Code:
    <?php
    
    print "Success";
    exit;
    
    ?>
    And lastly, the JavaScript file that sets up my form.

    Code:
    Ext.onReady(function(){
    	var F = new Ext.FormPanel({
    		renderTo: document.body,
    		labelAlign: "side",
    		frame: true,
    		autoHeight: true,
    		waitMsgTarget: false,
    		standardSubmit: true,
    		method: "GET",
    		baseParams: {id: 1},
    		url: "myProcess.php",
    		title: "My Form",
    		items: [{
    			title: "Name Fields",
    			xtype: "fieldset",
    			autoHeight: true,
    			defaults: {hideLabel: true, labelSeparator: ""},
    			items: {xtype: "textfield", name: "username"}
    		}],
    		buttons: [{
    			text: "Save",
    			handler: function() {
    				var O = this.ownerCt;
    				if (O.getForm().isValid()) {
    					if (O.url) O.getForm().getEl().dom.action = O.url;
    					if (O.baseParams) {
    						for (i in O.baseParams) {
    							O.add({
    								xtype: "hidden",
    								name: i,
    								value: O.baseParams[i]
    							})
    						}
    						O.doLayout();
    					}
    					O.getForm().submit();
    				}
    			}
    		}]
    	});
    });
    My script debugger seems to indicate an undefined variable on this line "if (O.getForm().isValid()) {"

    I'm at a loss. Any help would be greatly appreciated!

    Thank you!
    Mero.

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    In that handler function "this" is going to be the window.

    You need to use the scope config to Ext.Button to specify what you want "this" to refer to in the handler.

  3. #3
    Ext User
    Join Date
    Feb 2008
    Posts
    3
    Vote Rating
    0
    Merovingian is on a distinguished road

      0  

    Default


    Ahh, I understand what you're saying...

    So, do I specify something for the scope variable when I define the button?

    I'm not sure how to go about this.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    58
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    You should just be able to use "F" to refer to the FormPanel instead of attempting to use "this"

Thread Participants: 1