]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('Ext.app.ContactForm', {\r |
2 | extend: 'Ext.form.Panel',\r | |
3 | requires: [\r | |
4 | 'Ext.data.ArrayStore', \r | |
5 | 'Ext.data.reader.Array',\r | |
6 | 'Ext.form.field.ComboBox',\r | |
7 | 'Ext.form.field.Date'\r | |
8 | ],\r | |
9 | formTitle: 'Contact Information (English)',\r | |
10 | firstName: 'First Name',\r | |
11 | lastName: 'Surname',\r | |
12 | surnamePrefix: 'Surname Prefix',\r | |
13 | company: 'Company',\r | |
14 | state: 'State',\r | |
15 | stateEmptyText: 'Choose a state...',\r | |
16 | email: 'E-mail',\r | |
17 | birth: 'Date of Birth',\r | |
18 | save: 'Save',\r | |
19 | cancel: 'Cancel',\r | |
20 | initComponent : function(config) {\r | |
21 | Ext.apply(this, {\r | |
22 | url: 'save-form.php',\r | |
23 | frame: true,\r | |
24 | title: this.formTitle,\r | |
25 | bodyPadding: '5 5 0',\r | |
26 | width: 370,\r | |
27 | defaultType: 'textfield',\r | |
28 | defaults: {\r | |
29 | width: 330\r | |
30 | },\r | |
31 | items: [{\r | |
32 | fieldLabel: this.firstName,\r | |
33 | name: 'firstname',\r | |
34 | allowBlank:false\r | |
35 | },{\r | |
36 | fieldLabel: this.lastName,\r | |
37 | name: 'lastName'\r | |
38 | },{\r | |
39 | fieldLabel: this.surnamePrefix,\r | |
40 | width: 150,\r | |
41 | name: 'surnamePrefix'\r | |
42 | },{\r | |
43 | fieldLabel: this.company,\r | |
44 | name: 'company'\r | |
45 | }, Ext.create('Ext.form.field.ComboBox', {\r | |
46 | fieldLabel: this.province,\r | |
47 | hiddenName: 'state',\r | |
48 | store: Ext.create('Ext.data.ArrayStore', {\r | |
49 | fields: ['provincie'],\r | |
50 | data : Ext.exampledata.dutch_provinces // from dutch-provinces.js\r | |
51 | }),\r | |
52 | displayField: 'provincie',\r | |
53 | typeAhead: true,\r | |
54 | queryMode: 'local',\r | |
55 | triggerAction: 'all',\r | |
56 | emptyText: this.stateEmptyText,\r | |
57 | selectOnFocus:true\r | |
58 | }), {\r | |
59 | fieldLabel: this.email,\r | |
60 | name: 'email',\r | |
61 | vtype:'email'\r | |
62 | }, Ext.create('Ext.form.field.Date', {\r | |
63 | fieldLabel: this.birth,\r | |
64 | name: 'birth'\r | |
65 | })\r | |
66 | ],\r | |
67 | \r | |
68 | buttons: [{\r | |
69 | text: this.save\r | |
70 | },{\r | |
71 | text: this.cancel\r | |
72 | }]\r | |
73 | });\r | |
74 | \r | |
75 | this.callParent(arguments);\r | |
76 | }\r | |
77 | });\r | |
78 | \r | |
79 | Ext.require([\r | |
80 | 'Ext.tip.QuickTipManager'\r | |
81 | ]);\r | |
82 | \r | |
83 | Ext.onReady(function(){\r | |
84 | Ext.tip.QuickTipManager.init();\r | |
85 | \r | |
86 | // turn on validation errors beside the field globally\r | |
87 | Ext.form.field.Base.prototype.msgTarget = 'side';\r | |
88 | \r | |
89 | var bd = Ext.getBody();\r | |
90 | \r | |
91 | bd.createChild({tag: 'h2', html: 'Localized Contact Form'});\r | |
92 | \r | |
93 | // simple form\r | |
94 | var simple = Ext.create('Ext.app.ContactForm', {});\r | |
95 | simple.render(document.body);\r | |
96 | });\r |