Upgrade to ExtJS 3.2.1 - Released 04/27/2010
[extjs.git] / examples / form / xml-form.js
index 9876a8f..090f162 100644 (file)
-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-Ext.onReady(function(){\r
-\r
-    Ext.QuickTips.init();\r
-\r
-    // turn on validation errors beside the field globally\r
-    Ext.form.Field.prototype.msgTarget = 'side';\r
-\r
-    var fs = new Ext.FormPanel({\r
-        frame: true,\r
-        title:'XML Form',\r
-        labelAlign: 'right',\r
-        labelWidth: 85,\r
-        width:340,\r
-        waitMsgTarget: true,\r
-\r
-        // configure how to read the XML Data\r
-        reader : new Ext.data.XmlReader({\r
-            record : 'contact',\r
-            success: '@success'\r
-        }, [\r
-            {name: 'first', mapping:'name/first'}, // custom mapping\r
-            {name: 'last', mapping:'name/last'},\r
-            'company', 'email', 'state',\r
-            {name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types\r
-        ]),\r
-\r
-        // reusable eror reader class defined at the end of this file\r
-        errorReader: new Ext.form.XmlErrorReader(),\r
-\r
-        items: [\r
-            new Ext.form.FieldSet({\r
-                title: 'Contact Information',\r
-                autoHeight: true,\r
-                defaultType: 'textfield',\r
-                items: [{\r
-                        fieldLabel: 'First Name',\r
-                        name: 'first',\r
-                        width:190\r
-                    }, {\r
-                        fieldLabel: 'Last Name',\r
-                        name: 'last',\r
-                        width:190\r
-                    }, {\r
-                        fieldLabel: 'Company',\r
-                        name: 'company',\r
-                        width:190\r
-                    }, {\r
-                        fieldLabel: 'Email',\r
-                        name: 'email',\r
-                        vtype:'email',\r
-                        width:190\r
-                    },\r
-\r
-                    new Ext.form.ComboBox({\r
-                        fieldLabel: 'State',\r
-                        hiddenName:'state',\r
-                        store: new Ext.data.SimpleStore({\r
-                            fields: ['abbr', 'state'],\r
-                            data : Ext.exampledata.states // from states.js\r
-                        }),\r
-                        valueField:'abbr',\r
-                        displayField:'state',\r
-                        typeAhead: true,\r
-                        mode: 'local',\r
-                        triggerAction: 'all',\r
-                        emptyText:'Select a state...',\r
-                        selectOnFocus:true,\r
-                        width:190\r
-                    }),\r
-\r
-                    new Ext.form.DateField({\r
-                        fieldLabel: 'Date of Birth',\r
-                        name: 'dob',\r
-                        width:190,\r
-                        allowBlank:false\r
-                    })\r
-                ]\r
-            })\r
-        ]\r
-    });\r
-\r
-    // simple button add\r
-    fs.addButton('Load', function(){\r
-        fs.getForm().load({url:'xml-form.xml', waitMsg:'Loading'});\r
-    });\r
-\r
-    // explicit add\r
-    var submit = fs.addButton({\r
-        text: 'Submit',\r
-        disabled:true,\r
-        handler: function(){\r
-            fs.getForm().submit({url:'xml-errors.xml', waitMsg:'Saving Data...'});\r
-        }\r
-    });\r
-\r
-    fs.render('form-ct');\r
-\r
-    fs.on({\r
-        actioncomplete: function(form, action){\r
-            if(action.type == 'load'){\r
-                submit.enable();\r
-            }\r
-        }\r
-    });\r
-\r
-});\r
-\r
-// A reusable error reader class for XML forms\r
-Ext.form.XmlErrorReader = function(){\r
-    Ext.form.XmlErrorReader.superclass.constructor.call(this, {\r
-            record : 'field',\r
-            success: '@success'\r
-        }, [\r
-            'id', 'msg'\r
-        ]\r
-    );\r
-};\r
+/*!
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.onReady(function(){
+
+    Ext.QuickTips.init();
+
+    // turn on validation errors beside the field globally
+    Ext.form.Field.prototype.msgTarget = 'side';
+
+    var fs = new Ext.FormPanel({
+        frame: true,
+        title:'XML Form',
+        labelAlign: 'right',
+        labelWidth: 85,
+        width:340,
+        waitMsgTarget: true,
+
+        // configure how to read the XML Data
+        reader : new Ext.data.XmlReader({
+            record : 'contact',
+            success: '@success'
+        }, [
+            {name: 'first', mapping:'name/first'}, // custom mapping
+            {name: 'last', mapping:'name/last'},
+            'company', 'email', 'state',
+            {name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
+        ]),
+
+        // reusable eror reader class defined at the end of this file
+        errorReader: new Ext.form.XmlErrorReader(),
+
+        items: [
+            new Ext.form.FieldSet({
+                title: 'Contact Information',
+                autoHeight: true,
+                defaultType: 'textfield',
+                items: [{
+                        fieldLabel: 'First Name',
+                        emptyText: 'First Name',
+                        name: 'first',
+                        width:190
+                    }, {
+                        fieldLabel: 'Last Name',
+                        emptyText: 'Last Name',
+                        name: 'last',
+                        width:190
+                    }, {
+                        fieldLabel: 'Company',
+                        name: 'company',
+                        width:190
+                    }, {
+                        fieldLabel: 'Email',
+                        name: 'email',
+                        vtype:'email',
+                        width:190
+                    },
+
+                    new Ext.form.ComboBox({
+                        fieldLabel: 'State',
+                        hiddenName:'state',
+                        store: new Ext.data.ArrayStore({
+                            fields: ['abbr', 'state'],
+                            data : Ext.exampledata.states // from states.js
+                        }),
+                        valueField:'abbr',
+                        displayField:'state',
+                        typeAhead: true,
+                        mode: 'local',
+                        triggerAction: 'all',
+                        emptyText:'Select a state...',
+                        selectOnFocus:true,
+                        width:190
+                    }),
+
+                    new Ext.form.DateField({
+                        fieldLabel: 'Date of Birth',
+                        name: 'dob',
+                        width:190,
+                        allowBlank:false
+                    })
+                ]
+            })
+        ]
+    });
+
+    // simple button add
+    fs.addButton('Load', function(){
+        fs.getForm().load({url:'xml-form.xml', waitMsg:'Loading'});
+    });
+
+    // explicit add
+    var submit = fs.addButton({
+        text: 'Submit',
+        disabled:true,
+        handler: function(){
+            fs.getForm().submit({url:'xml-errors.xml', waitMsg:'Saving Data...', submitEmptyText: false});
+        }
+    });
+
+    fs.render('form-ct');
+
+    fs.on({
+        actioncomplete: function(form, action){
+            if(action.type == 'load'){
+                submit.enable();
+            }
+        }
+    });
+
+});
+
+// A reusable error reader class for XML forms
+Ext.form.XmlErrorReader = function(){
+    Ext.form.XmlErrorReader.superclass.constructor.call(this, {
+            record : 'field',
+            success: '@success'
+        }, [
+            'id', 'msg'
+        ]
+    );
+};
 Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);
\ No newline at end of file