3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.onReady(function(){
12 // turn on validation errors beside the field globally
13 Ext.form.Field.prototype.msgTarget = 'side';
15 var fs = new Ext.FormPanel({
23 // configure how to read the XML Data
24 reader : new Ext.data.XmlReader({
28 {name: 'first', mapping:'name/first'}, // custom mapping
29 {name: 'last', mapping:'name/last'},
30 'company', 'email', 'state',
31 {name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
34 // reusable eror reader class defined at the end of this file
35 errorReader: new Ext.form.XmlErrorReader(),
38 new Ext.form.FieldSet({
39 title: 'Contact Information',
41 defaultType: 'textfield',
43 fieldLabel: 'First Name',
47 fieldLabel: 'Last Name',
51 fieldLabel: 'Company',
61 new Ext.form.ComboBox({
64 store: new Ext.data.ArrayStore({
65 fields: ['abbr', 'state'],
66 data : Ext.exampledata.states // from states.js
73 emptyText:'Select a state...',
78 new Ext.form.DateField({
79 fieldLabel: 'Date of Birth',
90 fs.addButton('Load', function(){
91 fs.getForm().load({url:'xml-form.xml', waitMsg:'Loading'});
95 var submit = fs.addButton({
99 fs.getForm().submit({url:'xml-errors.xml', waitMsg:'Saving Data...'});
103 fs.render('form-ct');
106 actioncomplete: function(form, action){
107 if(action.type == 'load'){
115 // A reusable error reader class for XML forms
116 Ext.form.XmlErrorReader = function(){
117 Ext.form.XmlErrorReader.superclass.constructor.call(this, {
125 Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);</pre>
\r