]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * This is a very simple example of using XML for load and submit of data with an Ext\r | |
3 | * dynamic form.\r | |
4 | */\r | |
5 | Ext.define('KitchenSink.view.form.XmlForm', {\r | |
6 | extend: 'Ext.form.Panel',\r | |
7 | xtype: 'form-xml',\r | |
8 | controller: 'form-xml',\r | |
9 | \r | |
10 | //<example>\r | |
11 | requires: [\r | |
12 | 'Ext.data.reader.Xml',\r | |
13 | 'KitchenSink.model.form.Contact',\r | |
14 | 'KitchenSink.model.form.FieldError',\r | |
15 | 'KitchenSink.view.form.XmlFormController'\r | |
16 | ],\r | |
17 | \r | |
18 | exampleTitle: 'XML Form',\r | |
19 | otherContent: [{\r | |
20 | type: 'Contact Model',\r | |
21 | path: 'classic/samples/model/form/Contact.js'\r | |
22 | }, {\r | |
23 | type: 'FieldError Model',\r | |
24 | path: 'classic/samples/model/form/FieldError.js'\r | |
25 | }, {\r | |
26 | type: 'Store',\r | |
27 | path: 'classic/samples/store/States.js'\r | |
28 | }, {\r | |
29 | type: 'ViewController',\r | |
30 | path: 'classic/samples/view/form/XmlFormController.js'\r | |
31 | }, {\r | |
32 | type: 'Load XML',\r | |
33 | path: 'data/form/xml-form-data.xml'\r | |
34 | }, {\r | |
35 | type: 'Submit response',\r | |
36 | path: 'data/form/xml-form-errors.xml'\r | |
37 | }],\r | |
38 | //</example>\r | |
39 | \r | |
40 | title:'XML Form',\r | |
41 | frame: true,\r | |
42 | width: 340,\r | |
43 | bodyPadding: 5,\r | |
44 | waitMsgTarget: true,\r | |
45 | \r | |
46 | fieldDefaults: {\r | |
47 | labelAlign: 'right',\r | |
48 | labelWidth: 85,\r | |
49 | msgTarget: 'side'\r | |
50 | },\r | |
51 | \r | |
52 | // configure how to read the XML data, using an instance\r | |
53 | reader: {\r | |
54 | type: 'xml',\r | |
55 | model: 'KitchenSink.model.form.Contact',\r | |
56 | record: 'contact',\r | |
57 | successProperty: '@success'\r | |
58 | },\r | |
59 | \r | |
60 | // configure how to read the XML error, using a config\r | |
61 | errorReader: {\r | |
62 | type: 'xml',\r | |
63 | model: 'KitchenSink.model.form.FieldError',\r | |
64 | record : 'field',\r | |
65 | successProperty: '@success'\r | |
66 | },\r | |
67 | \r | |
68 | items: [{\r | |
69 | xtype: 'fieldset',\r | |
70 | title: 'Contact Information',\r | |
71 | defaultType: 'textfield',\r | |
72 | defaults: {\r | |
73 | width: 280\r | |
74 | },\r | |
75 | items: [{\r | |
76 | fieldLabel: 'First Name',\r | |
77 | emptyText: 'First Name',\r | |
78 | name: 'first'\r | |
79 | }, {\r | |
80 | fieldLabel: 'Last Name',\r | |
81 | emptyText: 'Last Name',\r | |
82 | name: 'last'\r | |
83 | }, {\r | |
84 | fieldLabel: 'Company',\r | |
85 | name: 'company'\r | |
86 | }, {\r | |
87 | fieldLabel: 'Email',\r | |
88 | name: 'email',\r | |
89 | vtype:'email'\r | |
90 | }, {\r | |
91 | xtype: 'combobox',\r | |
92 | fieldLabel: 'State',\r | |
93 | name: 'state',\r | |
94 | store: {\r | |
95 | type: 'states'\r | |
96 | },\r | |
97 | valueField: 'abbr',\r | |
98 | displayField: 'state',\r | |
99 | typeAhead: true,\r | |
100 | queryMode: 'local',\r | |
101 | emptyText: 'Select a state...'\r | |
102 | }, {\r | |
103 | xtype: 'datefield',\r | |
104 | fieldLabel: 'Date of Birth',\r | |
105 | name: 'dob',\r | |
106 | allowBlank: false,\r | |
107 | maxValue: new Date()\r | |
108 | }]\r | |
109 | }],\r | |
110 | \r | |
111 | buttons: [{\r | |
112 | text: 'Load',\r | |
113 | listeners: {\r | |
114 | click: 'onLoadClick'\r | |
115 | }\r | |
116 | }, {\r | |
117 | text: 'Submit',\r | |
118 | disabled: true,\r | |
119 | formBind: true,\r | |
120 | listeners: {\r | |
121 | click: 'onSubmitClick'\r | |
122 | }\r | |
123 | }]\r | |
124 | });\r |