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',
263 url: 'sample.data.json'
267 xtype : 'JsonReader',
269 totalProperty: 'totalCount',
289 xtype : 'HtmlEditor',
291 fieldLabel:'Biography',
294 resizable: 's', /// where the handles should got..
295 toolbars : [ 'ToolbarStandard', 'ToolbarContext' ]
302 mform.addButton('Save');
303 mform.addButton('Cancel');
306 mform.render('form-ct2');
309 countryNames : 'Alaska,Louisana',
310 countrylist : 'AG,AZ',
311 countrylist_names : 'Antigua and Barbuda,Azerbaijan'
314 * ================ Form 3 =======================
316 var fs = new Roo.form.Form({
322 {legend:'Contact Information', style: 'width:320px;' },
323 new Roo.form.TextField({
324 fieldLabel: 'First Name',
329 new Roo.form.TextField({
330 fieldLabel: 'Last Name',
335 new Roo.form.TextField({
336 fieldLabel: 'Company',
341 new Roo.form.TextField({
348 new Roo.form.ComboBox({
351 store: new Roo.data.SimpleStore({
352 fields: ['abbr', 'state'],
353 data : Roo.exampledata.states // from states.js
355 displayField:'state',
358 triggerAction: 'all',
359 emptyText:'Select a state...',
364 new Roo.form.DateField({
365 fieldLabel: 'Date of Birth',
370 new Roo.form.MonthField({
371 fieldLabel: 'Date of Month',
378 fs.addButton('Save');
379 fs.addButton('Cancel');
381 fs.render('form-ct3');
384 * ================ Form 4 =======================
386 var form = new Roo.form.Form({
391 form.column({width:342, labelWidth:75}); // open column, without auto close
393 {legend:'Contact Information'},
394 new Roo.form.TextField({
395 fieldLabel: 'Full Name',
401 new Roo.form.TextField({
402 fieldLabel: 'Job Title',
407 new Roo.form.TextField({
408 fieldLabel: 'Company',
413 new Roo.form.TextArea({
414 fieldLabel: 'Address',
417 preventScrollbars:true,
418 value: '123 example drive'
422 {legend:'Phone Numbers'},
423 new Roo.form.TextField({
426 value: '(123) 456 789'
429 new Roo.form.TextField({
430 fieldLabel: 'Business',
434 new Roo.form.TextField({
435 fieldLabel: 'Mobile',
439 new Roo.form.TextField({
444 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
448 {width:202, style:'margin-left:10px', clear:true}
452 {id:'photo', legend:'Photo'}
457 {legend:'Options', hideLabels:true},
458 new Roo.form.Checkbox({
459 boxLabel:'RooJS v1.1.1',
463 new Roo.form.Checkbox({
464 boxLabel:'RooJS v2.0.0',
468 new Roo.form.Checkbox({
469 boxLabel:'RooScript',
476 form.end(); // close the column
479 form.applyIfToFields({
483 form.addButton('Save');
484 form.addButton('Cancel');
486 form.render('form-ct4');
488 // The form elements are standard HTML elements. By assigning an id (as we did above)
489 // we can manipulate them like any other element
490 var photo = Roo.get('photo');
491 var c = photo.createChild({
495 src: 'roojs_icon.jpg',
496 style:'margin-bottom:5px;'
503 form5 = new Roo.form.Form({
511 fieldLabel: 'A checkbox',
512 boxLabel:'RooJS v1.1.1',
523 fieldLabel: 'A test radio box',
533 fieldLabel: 'A test radio box2',
544 fieldLabel: 'A checkbox',
545 boxLabel:'RooJS v1.1.1',
554 xtype : 'DisplayField',
557 fieldLabel: 'Simple',
558 value : 'example text'
566 xtype: 'SimpleStore',
568 fields: ['abbr', 'state'],
569 data : Roo.exampledata.states // from states.js
571 displayField:'state',
574 triggerAction: 'all',
575 emptyText:'Select a state...',
581 Roo.MessageBox.alert("Alert", "Add Pressed");
585 Roo.MessageBox.alert("Alert", "Edit Pressed");
594 form5.render('form-ct5');
597 // form6 = new Roo.form.Form({
598 // labelAlign: 'left',
603 // xtype: 'TimePicker',
605 // fieldLabel: 'test time picker',
609 // xtype: 'DateDisplay',
611 // fieldLabel: 'test date picker',
619 // form6.render('form-ct6');
624 * ================ form 7 =======================
626 signature = new Roo.form.Form({
627 labelWidth: 75, // label settings here cascade unless overridden
632 new Roo.form.Signature({
633 fieldLabel: 'Signature',
636 confirm : function (_self)
638 Roo.log(_self.getImageDataURI());
639 Roo.log('in confirm');
646 // form7.addButton('Save');
647 // form7.addButton('Cancel');
649 signature.render('form-ct7');