4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
15 Roo.onReady(function(){
19 // turn on validation errors beside the field globally
20 Roo.form.Field.prototype.msgTarget = 'side';
23 * ================ Simple form =======================
25 simple = new Roo.form.Form({
26 labelWidth: 75, // label settings here cascade unless overridden
30 new Roo.form.TextField({
31 fieldLabel: 'First Name',
37 new Roo.form.TextField({
38 fieldLabel: 'Last Name',
43 new Roo.form.TextField({
44 fieldLabel: 'Company',
49 new Roo.form.TextField({
55 new Roo.form.DayPicker({
56 fieldLabel: 'Pick a day',
62 simple.addButton('Save');
63 simple.addButton('Cancel');
65 simple.render('form-ct');
69 * ================ Form 2 =======================
71 mform = new Roo.form.Form({
78 width: 500, // precise column sizes or percentages or straight CSS
81 xtype : 'ComboBoxArray',
83 fieldLabel: 'Multi select test',
85 hiddenName: 'countryNames',
93 xtype : 'SimpleStore',
95 fields: ['abbr', 'state'],
96 data : Roo.exampledata.states // from states.js
100 displayField:'state',
103 triggerAction: 'all',
104 emptyText:'Select a state...',
118 width: 272, // precise column sizes or percentages or straight CSS
122 fieldLabel: 'First Name',
128 fieldLabel: 'Company',
138 style:'margin-left:10px',
143 fieldLabel: 'Last Name',
163 xtype : 'HtmlEditor',
165 fieldLabel:'Biography',
168 resizable: 's' /// where the handles should got..
175 mform.addButton('Save');
176 mform.addButton('Cancel');
179 mform.render('form-ct2');
182 countryNames : 'Hong Kong, Singapore'
187 * ================ Form 3 =======================
189 var fs = new Roo.form.Form({
195 {legend:'Contact Information', style: 'width:320px;' },
196 new Roo.form.TextField({
197 fieldLabel: 'First Name',
202 new Roo.form.TextField({
203 fieldLabel: 'Last Name',
208 new Roo.form.TextField({
209 fieldLabel: 'Company',
214 new Roo.form.TextField({
221 new Roo.form.ComboBox({
224 store: new Roo.data.SimpleStore({
225 fields: ['abbr', 'state'],
226 data : Roo.exampledata.states // from states.js
228 displayField:'state',
231 triggerAction: 'all',
232 emptyText:'Select a state...',
237 new Roo.form.DateField({
238 fieldLabel: 'Date of Birth',
245 fs.addButton('Save');
246 fs.addButton('Cancel');
248 fs.render('form-ct3');
251 * ================ Form 4 =======================
253 var form = new Roo.form.Form({
258 form.column({width:342, labelWidth:75}); // open column, without auto close
260 {legend:'Contact Information'},
261 new Roo.form.TextField({
262 fieldLabel: 'Full Name',
268 new Roo.form.TextField({
269 fieldLabel: 'Job Title',
274 new Roo.form.TextField({
275 fieldLabel: 'Company',
280 new Roo.form.TextArea({
281 fieldLabel: 'Address',
284 preventScrollbars:true,
285 value: '123 example drive'
289 {legend:'Phone Numbers'},
290 new Roo.form.TextField({
293 value: '(123) 456 789'
296 new Roo.form.TextField({
297 fieldLabel: 'Business',
301 new Roo.form.TextField({
302 fieldLabel: 'Mobile',
306 new Roo.form.TextField({
311 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
315 {width:202, style:'margin-left:10px', clear:true}
319 {id:'photo', legend:'Photo'}
324 {legend:'Options', hideLabels:true},
325 new Roo.form.Checkbox({
326 boxLabel:'RooJS v1.1.1',
330 new Roo.form.Checkbox({
331 boxLabel:'RooJS v2.0.0',
335 new Roo.form.Checkbox({
336 boxLabel:'RooScript',
343 form.end(); // close the column
346 form.applyIfToFields({
350 form.addButton('Save');
351 form.addButton('Cancel');
353 form.render('form-ct4');
355 // The form elements are standard HTML elements. By assigning an id (as we did above)
356 // we can manipulate them like any other element
357 var photo = Roo.get('photo');
358 var c = photo.createChild({
362 src: 'roojs_icon.jpg',
363 style:'margin-bottom:5px;'
370 form5 = new Roo.form.Form({
378 fieldLabel: 'A checkbox',
379 boxLabel:'RooJS v1.1.1',
386 xtype : 'DisplayField',
389 fieldLabel: 'Simple',
390 value : 'example text'
398 xtype: 'SimpleStore',
400 fields: ['abbr', 'state'],
401 data : Roo.exampledata.states // from states.js
403 displayField:'state',
406 triggerAction: 'all',
407 emptyText:'Select a state...',
413 Roo.MessageBox.alert("Alert", "Add Pressed");
417 Roo.MessageBox.alert("Alert", "Edit Pressed");
426 form5.render('form-ct5');