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">
16 Roo.onReady(function(){
20 // turn on validation errors beside the field globally
21 Roo.form.Field.prototype.msgTarget = 'side';
24 * ================ Simple form =======================
26 simple = new Roo.form.Form({
27 labelWidth: 75, // label settings here cascade unless overridden
31 new Roo.form.TextField({
32 fieldLabel: 'First Name',
38 new Roo.form.TextField({
39 fieldLabel: 'Last Name',
46 new Roo.form.TextField({
47 fieldLabel: 'Company',
51 new Roo.form.TextField({
52 fieldLabel: 'Password',
54 inputType: 'password',
58 new Roo.form.TextField({
64 new Roo.form.DayPicker({
65 fieldLabel: 'Pick a day',
71 simple.addButton('Save');
72 simple.addButton('Cancel');
74 simple.render('form-ct');
78 * ================ Form 2 =======================
80 mform = new Roo.form.Form({
87 width: 500, // precise column sizes or percentages or straight CSS
90 xtype : 'ComboBoxArray',
92 fieldLabel: 'Multi select test',
94 hiddenName: 'country',
100 displayField : 'state',
102 name : 'countryNames',
103 hiddenName : 'country',
108 xtype : 'SimpleStore',
110 fields: ['abbr', 'state'],
111 data : Roo.exampledata.states // from states.js
119 triggerAction: 'all',
120 emptyText:'Select a state...',
135 width: 500, // precise column sizes or percentages or straight CSS
138 xtype : 'ComboBoxArray',
140 fieldLabel: 'Multi select test',
143 name: 'countrylist_names',
144 hiddenName: 'countrylist',
150 displayField : 'title',
152 // thes are not really needed as parent overwrites them!?
153 name : 'country_name',
154 hiddenName : 'country',
169 xtype : 'ScriptTagProxy',
170 url: 'http://www.roojs.com/forum/topics-remote.php'
174 xtype : 'JsonReader',
176 totalProperty: 'totalCount',
179 {name: 'title', mapping: 'topic_title'},
180 {name: 'topicId', mapping: 'topic_id'},
181 {name: 'author', mapping: 'author'},
182 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
183 {name: 'excerpt', mapping: 'post_text'}
193 triggerAction: 'all',
194 emptyText:'Select a state...',
213 width: 272, // precise column sizes or percentages or straight CSS
217 fieldLabel: 'First Name',
223 fieldLabel: 'Company',
233 style:'margin-left:10px',
238 fieldLabel: 'Last Name',
252 fieldLabel: 'Country',
257 displayField : 'title',
258 emptyText : 'Select a country',
266 url: 'sample.data.json'
270 xtype : 'JsonReader',
272 totalProperty: 'totalCount',
292 xtype : 'HtmlEditor',
294 fieldLabel:'Biography',
297 resizable: 's', /// where the handles should got..
298 toolbars : [ 'ToolbarStandard', 'ToolbarContext' ]
305 mform.addButton('Save');
306 mform.addButton('Cancel');
309 mform.render('form-ct2');
312 countryNames : 'Alaska,Louisana',
313 countrylist : 'AG,AZ',
314 countrylist_names : 'Antigua and Barbuda,Azerbaijan'
318 * ================ Form 3 =======================
320 var fs = new Roo.form.Form({
326 {legend:'Contact Information', style: 'width:320px;' },
327 new Roo.form.TextField({
328 fieldLabel: 'First Name',
333 new Roo.form.TextField({
334 fieldLabel: 'Last Name',
339 new Roo.form.TextField({
340 fieldLabel: 'Company',
345 new Roo.form.TextField({
352 new Roo.form.ComboBox({
355 store: new Roo.data.SimpleStore({
356 fields: ['abbr', 'state'],
357 data : Roo.exampledata.states // from states.js
359 displayField:'state',
362 triggerAction: 'all',
363 emptyText:'Select a state...',
368 new Roo.form.DateField({
369 fieldLabel: 'Date of Birth',
374 new Roo.form.MonthField({
375 fieldLabel: 'Date of Month',
382 fs.addButton('Save');
383 fs.addButton('Cancel');
385 fs.render('form-ct3');
388 * ================ Form 4 =======================
390 var form = new Roo.form.Form({
395 form.column({width:342, labelWidth:75}); // open column, without auto close
397 {legend:'Contact Information'},
398 new Roo.form.TextField({
399 fieldLabel: 'Full Name',
405 new Roo.form.TextField({
406 fieldLabel: 'Job Title',
411 new Roo.form.TextField({
412 fieldLabel: 'Company',
417 new Roo.form.TextArea({
418 fieldLabel: 'Address',
421 preventScrollbars:true,
422 value: '123 example drive'
426 {legend:'Phone Numbers'},
427 new Roo.form.TextField({
430 value: '(123) 456 789'
433 new Roo.form.TextField({
434 fieldLabel: 'Business',
438 new Roo.form.TextField({
439 fieldLabel: 'Mobile',
443 new Roo.form.TextField({
448 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
452 {width:202, style:'margin-left:10px', clear:true}
456 {id:'photo', legend:'Photo'}
461 {legend:'Options', hideLabels:true},
462 new Roo.form.Checkbox({
463 boxLabel:'RooJS v1.1.1',
467 new Roo.form.Checkbox({
468 boxLabel:'RooJS v2.0.0',
472 new Roo.form.Checkbox({
473 boxLabel:'RooScript',
480 form.end(); // close the column
483 form.applyIfToFields({
487 form.addButton('Save');
488 form.addButton('Cancel');
490 form.render('form-ct4');
492 // The form elements are standard HTML elements. By assigning an id (as we did above)
493 // we can manipulate them like any other element
494 var photo = Roo.get('photo');
495 var c = photo.createChild({
499 src: 'roojs_icon.jpg',
500 style:'margin-bottom:5px;'
507 form5 = new Roo.form.Form({
515 fieldLabel: 'A checkbox',
516 boxLabel:'RooJS v1.1.1',
527 fieldLabel: 'A test radio box',
537 fieldLabel: 'A test radio box2',
548 fieldLabel: 'A checkbox',
549 boxLabel:'RooJS v1.1.1',
558 xtype : 'DisplayField',
561 fieldLabel: 'Simple',
562 value : 'example text'
570 xtype: 'SimpleStore',
572 fields: ['abbr', 'state'],
573 data : Roo.exampledata.states // from states.js
575 displayField:'state',
578 triggerAction: 'all',
579 emptyText:'Select a state...',
585 Roo.MessageBox.alert("Alert", "Add Pressed");
589 Roo.MessageBox.alert("Alert", "Edit Pressed");
598 form5.render('form-ct5');
601 // form6 = new Roo.form.Form({
602 // labelAlign: 'left',
607 // xtype: 'TimePicker',
609 // fieldLabel: 'test time picker',
613 // xtype: 'DateDisplay',
615 // fieldLabel: 'test date picker',
623 // form6.render('form-ct6');
628 * ================ form 7 =======================
630 signature = new Roo.form.Form({
631 labelWidth: 75, // label settings here cascade unless overridden
636 new Roo.form.Signature({
637 fieldLabel: 'Signature',
640 confirm : function (_self)
642 Roo.log(_self.getImageDataURI());
643 Roo.log('in confirm');
650 // form7.addButton('Save');
651 // form7.addButton('Cancel');
653 signature.render('form-ct7');