3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
7 Ext.onReady(function(){
11 // turn on validation errors beside the field globally
12 Ext.form.Field.prototype.msgTarget = 'side';
14 var fs = new Ext.FormPanel({
22 // configure how to read the XML Data
23 reader : new Ext.data.XmlReader({
27 {name: 'first', mapping:'name/first'}, // custom mapping
28 {name: 'last', mapping:'name/last'},
29 'company', 'email', 'state',
30 {name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types
33 // reusable eror reader class defined at the end of this file
34 errorReader: new Ext.form.XmlErrorReader(),
37 new Ext.form.FieldSet({
38 title: 'Contact Information',
40 defaultType: 'textfield',
42 fieldLabel: 'First Name',
43 emptyText: 'First Name',
47 fieldLabel: 'Last Name',
48 emptyText: 'Last Name',
52 fieldLabel: 'Company',
62 new Ext.form.ComboBox({
65 store: new Ext.data.ArrayStore({
66 fields: ['abbr', 'state'],
67 data : Ext.exampledata.states // from states.js
74 emptyText:'Select a state...',
79 new Ext.form.DateField({
80 fieldLabel: 'Date of Birth',
91 fs.addButton('Load', function(){
92 fs.getForm().load({url:'xml-form.xml', waitMsg:'Loading'});
96 var submit = fs.addButton({
100 fs.getForm().submit({url:'xml-errors.xml', waitMsg:'Saving Data...', submitEmptyText: false});
104 fs.render('form-ct');
107 actioncomplete: function(form, action){
108 if(action.type == 'load'){
116 // A reusable error reader class for XML forms
117 Ext.form.XmlErrorReader = function(){
118 Ext.form.XmlErrorReader.superclass.constructor.call(this, {
126 Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);