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',
44 new Roo.form.TextField({
45 fieldLabel: 'Company',
49 new Roo.form.TextField({
50 fieldLabel: 'Password',
52 inputType: 'password',
56 new Roo.form.TextField({
62 new Roo.form.DayPicker({
63 fieldLabel: 'Pick a day',
69 simple.addButton('Save');
70 simple.addButton('Cancel');
72 simple.render('form-ct');
76 * ================ Form 2 =======================
78 mform = new Roo.form.Form({
85 width: 500, // precise column sizes or percentages or straight CSS
88 xtype : 'ComboBoxArray',
90 fieldLabel: 'Multi select test',
92 hiddenName: 'country',
98 displayField : 'state',
100 name : 'countryNames',
101 hiddenName : 'country',
106 xtype : 'SimpleStore',
108 fields: ['abbr', 'state'],
109 data : Roo.exampledata.states // from states.js
117 triggerAction: 'all',
118 emptyText:'Select a state...',
133 width: 500, // precise column sizes or percentages or straight CSS
136 xtype : 'ComboBoxArray',
138 fieldLabel: 'Multi select test',
141 name: 'countrylist_names',
142 hiddenName: 'countrylist',
148 displayField : 'title',
150 // thes are not really needed as parent overwrites them!?
151 name : 'country_name',
152 hiddenName : 'country',
167 xtype : 'ScriptTagProxy',
168 url: 'http://www.roojs.com/forum/topics-remote.php'
172 xtype : 'JsonReader',
174 totalProperty: 'totalCount',
177 {name: 'title', mapping: 'topic_title'},
178 {name: 'topicId', mapping: 'topic_id'},
179 {name: 'author', mapping: 'author'},
180 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
181 {name: 'excerpt', mapping: 'post_text'}
191 triggerAction: 'all',
192 emptyText:'Select a state...',
211 width: 272, // precise column sizes or percentages or straight CSS
215 fieldLabel: 'First Name',
221 fieldLabel: 'Company',
231 style:'margin-left:10px',
236 fieldLabel: 'Last Name',
256 xtype : 'HtmlEditor',
258 fieldLabel:'Biography',
261 resizable: 's', /// where the handles should got..
262 toolbars : [ 'ToolbarStandard', 'ToolbarContext' ]
269 mform.addButton('Save');
270 mform.addButton('Cancel');
273 mform.render('form-ct2');
276 countryNames : 'Alaska,Louisana',
277 countrylist : 'AG,AZ',
278 countrylist_names : 'Antigua and Barbuda,Azerbaijan'
281 * ================ Form 3 =======================
283 var fs = new Roo.form.Form({
289 {legend:'Contact Information', style: 'width:320px;' },
290 new Roo.form.TextField({
291 fieldLabel: 'First Name',
296 new Roo.form.TextField({
297 fieldLabel: 'Last Name',
302 new Roo.form.TextField({
303 fieldLabel: 'Company',
308 new Roo.form.TextField({
315 new Roo.form.ComboBox({
318 store: new Roo.data.SimpleStore({
319 fields: ['abbr', 'state'],
320 data : Roo.exampledata.states // from states.js
322 displayField:'state',
325 triggerAction: 'all',
326 emptyText:'Select a state...',
331 new Roo.form.DateField({
332 fieldLabel: 'Date of Birth',
337 new Roo.form.MonthField({
338 fieldLabel: 'Date of Month',
345 fs.addButton('Save');
346 fs.addButton('Cancel');
348 fs.render('form-ct3');
351 * ================ Form 4 =======================
353 var form = new Roo.form.Form({
358 form.column({width:342, labelWidth:75}); // open column, without auto close
360 {legend:'Contact Information'},
361 new Roo.form.TextField({
362 fieldLabel: 'Full Name',
368 new Roo.form.TextField({
369 fieldLabel: 'Job Title',
374 new Roo.form.TextField({
375 fieldLabel: 'Company',
380 new Roo.form.TextArea({
381 fieldLabel: 'Address',
384 preventScrollbars:true,
385 value: '123 example drive'
389 {legend:'Phone Numbers'},
390 new Roo.form.TextField({
393 value: '(123) 456 789'
396 new Roo.form.TextField({
397 fieldLabel: 'Business',
401 new Roo.form.TextField({
402 fieldLabel: 'Mobile',
406 new Roo.form.TextField({
411 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
415 {width:202, style:'margin-left:10px', clear:true}
419 {id:'photo', legend:'Photo'}
424 {legend:'Options', hideLabels:true},
425 new Roo.form.Checkbox({
426 boxLabel:'RooJS v1.1.1',
430 new Roo.form.Checkbox({
431 boxLabel:'RooJS v2.0.0',
435 new Roo.form.Checkbox({
436 boxLabel:'RooScript',
443 form.end(); // close the column
446 form.applyIfToFields({
450 form.addButton('Save');
451 form.addButton('Cancel');
453 form.render('form-ct4');
455 // The form elements are standard HTML elements. By assigning an id (as we did above)
456 // we can manipulate them like any other element
457 var photo = Roo.get('photo');
458 var c = photo.createChild({
462 src: 'roojs_icon.jpg',
463 style:'margin-bottom:5px;'
470 form5 = new Roo.form.Form({
478 fieldLabel: 'A checkbox',
479 boxLabel:'RooJS v1.1.1',
486 xtype : 'DisplayField',
489 fieldLabel: 'Simple',
490 value : 'example text'
498 xtype: 'SimpleStore',
500 fields: ['abbr', 'state'],
501 data : Roo.exampledata.states // from states.js
503 displayField:'state',
506 triggerAction: 'all',
507 emptyText:'Select a state...',
513 Roo.MessageBox.alert("Alert", "Add Pressed");
517 Roo.MessageBox.alert("Alert", "Edit Pressed");
526 form5.render('form-ct5');
529 // form6 = new Roo.form.Form({
530 // labelAlign: 'left',
535 // xtype: 'TimePicker',
537 // fieldLabel: 'test time picker',
541 // xtype: 'DateDisplay',
543 // fieldLabel: 'test date picker',
551 // form6.render('form-ct6');
556 * ================ form 7 =======================
558 var signature = new Roo.form.Form({
559 labelWidth: 75, // label settings here cascade unless overridden
563 new Roo.form.Signature({
564 fieldLabel: 'Signature',
570 // form7.addButton('Save');
571 // form7.addButton('Cancel');
573 signature.render('form-ct7');