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: 'country',
91 displayField : 'state',
93 name : 'countryNames',
94 hiddenName : 'country',
99 xtype : 'SimpleStore',
101 fields: ['abbr', 'state'],
102 data : Roo.exampledata.states // from states.js
110 triggerAction: 'all',
111 emptyText:'Select a state...',
126 width: 500, // precise column sizes or percentages or straight CSS
129 xtype : 'ComboBoxArray',
131 fieldLabel: 'Multi select test',
132 name: 'countryNames',
133 hiddenName: 'country',
139 displayField : 'state',
141 name : 'countryNames',
142 hiddenName : 'country',
157 xtype : 'ScriptTagProxy',
158 url: 'http://www.roojs.com/forum/topics-remote.php'
162 xtype : 'JsonReader',
164 totalProperty: 'totalCount',
167 {name: 'title', mapping: 'topic_title'},
168 {name: 'topicId', mapping: 'topic_id'},
169 {name: 'author', mapping: 'author'},
170 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
171 {name: 'excerpt', mapping: 'post_text'}
181 triggerAction: 'all',
182 emptyText:'Select a state...',
201 width: 272, // precise column sizes or percentages or straight CSS
205 fieldLabel: 'First Name',
211 fieldLabel: 'Company',
221 style:'margin-left:10px',
226 fieldLabel: 'Last Name',
246 xtype : 'HtmlEditor',
248 fieldLabel:'Biography',
251 resizable: 's' /// where the handles should got..
258 mform.addButton('Save');
259 mform.addButton('Cancel');
262 mform.render('form-ct2');
265 countryNames : 'Alaska,Louisana'
270 * ================ Form 3 =======================
272 var fs = new Roo.form.Form({
278 {legend:'Contact Information', style: 'width:320px;' },
279 new Roo.form.TextField({
280 fieldLabel: 'First Name',
285 new Roo.form.TextField({
286 fieldLabel: 'Last Name',
291 new Roo.form.TextField({
292 fieldLabel: 'Company',
297 new Roo.form.TextField({
304 new Roo.form.ComboBox({
307 store: new Roo.data.SimpleStore({
308 fields: ['abbr', 'state'],
309 data : Roo.exampledata.states // from states.js
311 displayField:'state',
314 triggerAction: 'all',
315 emptyText:'Select a state...',
320 new Roo.form.DateField({
321 fieldLabel: 'Date of Birth',
328 fs.addButton('Save');
329 fs.addButton('Cancel');
331 fs.render('form-ct3');
334 * ================ Form 4 =======================
336 var form = new Roo.form.Form({
341 form.column({width:342, labelWidth:75}); // open column, without auto close
343 {legend:'Contact Information'},
344 new Roo.form.TextField({
345 fieldLabel: 'Full Name',
351 new Roo.form.TextField({
352 fieldLabel: 'Job Title',
357 new Roo.form.TextField({
358 fieldLabel: 'Company',
363 new Roo.form.TextArea({
364 fieldLabel: 'Address',
367 preventScrollbars:true,
368 value: '123 example drive'
372 {legend:'Phone Numbers'},
373 new Roo.form.TextField({
376 value: '(123) 456 789'
379 new Roo.form.TextField({
380 fieldLabel: 'Business',
384 new Roo.form.TextField({
385 fieldLabel: 'Mobile',
389 new Roo.form.TextField({
394 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
398 {width:202, style:'margin-left:10px', clear:true}
402 {id:'photo', legend:'Photo'}
407 {legend:'Options', hideLabels:true},
408 new Roo.form.Checkbox({
409 boxLabel:'RooJS v1.1.1',
413 new Roo.form.Checkbox({
414 boxLabel:'RooJS v2.0.0',
418 new Roo.form.Checkbox({
419 boxLabel:'RooScript',
426 form.end(); // close the column
429 form.applyIfToFields({
433 form.addButton('Save');
434 form.addButton('Cancel');
436 form.render('form-ct4');
438 // The form elements are standard HTML elements. By assigning an id (as we did above)
439 // we can manipulate them like any other element
440 var photo = Roo.get('photo');
441 var c = photo.createChild({
445 src: 'roojs_icon.jpg',
446 style:'margin-bottom:5px;'
453 form5 = new Roo.form.Form({
461 fieldLabel: 'A checkbox',
462 boxLabel:'RooJS v1.1.1',
469 xtype : 'DisplayField',
472 fieldLabel: 'Simple',
473 value : 'example text'
481 xtype: 'SimpleStore',
483 fields: ['abbr', 'state'],
484 data : Roo.exampledata.states // from states.js
486 displayField:'state',
489 triggerAction: 'all',
490 emptyText:'Select a state...',
496 Roo.MessageBox.alert("Alert", "Add Pressed");
500 Roo.MessageBox.alert("Alert", "Edit Pressed");
509 form5.render('form-ct5');