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 bd = Ext.getBody();
18 * ================ Simple form =======================
20 bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'});
23 var simple = new Ext.FormPanel({
24 labelWidth: 75, // label settings here cascade unless overridden
28 bodyStyle:'padding:5px 5px 0',
30 defaults: {width: 230},
31 defaultType: 'textfield',
34 fieldLabel: 'First Name',
38 fieldLabel: 'Last Name',
41 fieldLabel: 'Company',
47 }, new Ext.form.TimeField({
62 simple.render(document.body);
66 * ================ Form 2 =======================
68 bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'});
70 var fsf = new Ext.FormPanel({
71 labelWidth: 75, // label settings here cascade unless overridden
74 title: 'Simple Form with FieldSets',
75 bodyStyle:'padding:5px 5px 0',
81 title: 'User Information',
83 defaults: {width: 210},
84 defaultType: 'textfield',
87 fieldLabel: 'First Name',
91 fieldLabel: 'Last Name',
94 fieldLabel: 'Company',
104 title: 'Phone Number',
107 defaults: {width: 210},
108 defaultType: 'textfield',
112 value: '(888) 555-1212'
114 fieldLabel: 'Business',
117 fieldLabel: 'Mobile',
133 fsf.render(document.body);
136 * ================ Form 3 =======================
138 bd.createChild({tag: 'h2', html: 'Form 3 - A little more complex'});
141 var top = new Ext.FormPanel({
144 title: 'Multi Column, Nested Layouts and Anchoring',
145 bodyStyle:'padding:5px 5px 0',
154 fieldLabel: 'First Name',
159 fieldLabel: 'Company',
168 fieldLabel: 'Last Name',
182 fieldLabel:'Biography',
194 top.render(document.body);
198 * ================ Form 4 =======================
200 bd.createChild({tag: 'h2', html: 'Form 4 - Forms can be a TabPanel...'});
204 var tabs = new Ext.FormPanel({
212 defaults:{autoHeight:true, bodyStyle:'padding:10px'},
214 title:'Personal Details',
216 defaults: {width: 230},
217 defaultType: 'textfield',
220 fieldLabel: 'First Name',
225 fieldLabel: 'Last Name',
229 fieldLabel: 'Company',
238 title:'Phone Numbers',
240 defaults: {width: 230},
241 defaultType: 'textfield',
246 value: '(888) 555-1212'
248 fieldLabel: 'Business',
251 fieldLabel: 'Mobile',
267 tabs.render(document.body);
272 * ================ Form 5 =======================
274 bd.createChild({tag: 'h2', html: 'Form 5 - ... and forms can contain TabPanel(s)'});
276 var tab2 = new Ext.FormPanel({
279 bodyStyle:'padding:5px',
290 fieldLabel: 'First Name',
295 fieldLabel: 'Company',
305 fieldLabel: 'Last Name',
321 defaults:{bodyStyle:'padding:10px'},
323 title:'Personal Details',
325 defaults: {width: 230},
326 defaultType: 'textfield',
329 fieldLabel: 'First Name',
334 fieldLabel: 'Last Name',
338 fieldLabel: 'Company',
347 title:'Phone Numbers',
349 defaults: {width: 230},
350 defaultType: 'textfield',
355 value: '(888) 555-1212'
357 fieldLabel: 'Business',
360 fieldLabel: 'Mobile',
373 fieldLabel:'Biography'
385 tab2.render(document.body);