Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / examples / locale / ContactForm.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 Ext.define('Ext.app.ContactForm', {
16     extend: 'Ext.form.Panel',
17     requires: [
18      'Ext.data.ArrayStore',
19      'Ext.data.reader.Array',
20      'Ext.form.field.ComboBox',
21      'Ext.form.field.Date'
22     ],
23     formTitle: 'Contact Information (English)',
24     firstName: 'First Name',
25     lastName: 'Surname',
26     surnamePrefix: 'Surname Prefix',
27     company: 'Company',
28     state: 'State',
29     stateEmptyText: 'Choose a state...',
30     email: 'E-mail',
31     birth: 'Date of Birth',
32     save: 'Save',
33     cancel: 'Cancel',
34     initComponent : function(config) {
35         Ext.apply(this, {
36             url: 'save-form.php',
37             frame: true,
38             title: this.formTitle,
39             bodyStyle: 'padding:5px 5px 0',
40             width: 370,
41             defaultType: 'textfield',
42             defaults: {
43                 width: 330
44             },
45             items: [{
46                     fieldLabel: this.firstName,
47                     name: 'firstname',
48                     allowBlank:false
49                 },{
50                     fieldLabel: this.lastName,
51                     name: 'lastName'
52                 },{
53                     fieldLabel: this.surnamePrefix,
54                     width: 150,
55                     name: 'surnamePrefix'
56                 },{
57                     fieldLabel: this.company,
58                     name: 'company'
59                 },  Ext.create('Ext.form.field.ComboBox', {
60                     fieldLabel: this.province,
61                     hiddenName: 'state',
62                     store: Ext.create('Ext.data.ArrayStore', {
63                         fields: ['provincie'],
64                         data : Ext.exampledata.dutch_provinces // from dutch-provinces.js
65                     }),
66                     displayField: 'provincie',
67                     typeAhead: true,
68                     queryMode: 'local',
69                     triggerAction: 'all',
70                     emptyText: this.stateEmptyText,
71                     selectOnFocus:true
72                 }), {
73                     fieldLabel: this.email,
74                     name: 'email',
75                     vtype:'email'
76                 }, Ext.create('Ext.form.field.Date', {
77                     fieldLabel: this.birth,
78                     name: 'birth'
79                 })
80             ],
81
82             buttons: [{
83                 text: this.save
84             },{
85                 text: this.cancel
86             }]
87         });
88
89         this.callParent(arguments);
90     }
91 });
92
93 Ext.require([
94    'Ext.tip.QuickTipManager'
95 ]);
96
97 Ext.onReady(function(){
98     Ext.tip.QuickTipManager.init();
99
100     // turn on validation errors beside the field globally
101     Ext.form.field.Base.prototype.msgTarget = 'side';
102
103     var bd = Ext.getBody();
104
105     bd.createChild({tag: 'h2', html: 'Localized Contact Form'});
106
107     // simple form
108     var simple = Ext.create('Ext.app.ContactForm', {});
109     simple.render(document.body);
110 });
111