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: 'countryNames2',
133 hiddenName: 'country2',
139 displayField : 'state',
141 // thes are not really needed as parent overwrites them!?
142 name : 'countryNames',
143 hiddenName : 'country',
158 xtype : 'ScriptTagProxy',
159 url: 'http://www.roojs.com/forum/topics-remote.php'
163 xtype : 'JsonReader',
165 totalProperty: 'totalCount',
168 {name: 'title', mapping: 'topic_title'},
169 {name: 'topicId', mapping: 'topic_id'},
170 {name: 'author', mapping: 'author'},
171 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
172 {name: 'excerpt', mapping: 'post_text'}
182 triggerAction: 'all',
183 emptyText:'Select a state...',
202 width: 272, // precise column sizes or percentages or straight CSS
206 fieldLabel: 'First Name',
212 fieldLabel: 'Company',
222 style:'margin-left:10px',
227 fieldLabel: 'Last Name',
247 xtype : 'HtmlEditor',
249 fieldLabel:'Biography',
252 resizable: 's' /// where the handles should got..
259 mform.addButton('Save');
260 mform.addButton('Cancel');
263 mform.render('form-ct2');
266 countryNames : 'Alaska,Louisana'
271 * ================ Form 3 =======================
273 var fs = new Roo.form.Form({
279 {legend:'Contact Information', style: 'width:320px;' },
280 new Roo.form.TextField({
281 fieldLabel: 'First Name',
286 new Roo.form.TextField({
287 fieldLabel: 'Last Name',
292 new Roo.form.TextField({
293 fieldLabel: 'Company',
298 new Roo.form.TextField({
305 new Roo.form.ComboBox({
308 store: new Roo.data.SimpleStore({
309 fields: ['abbr', 'state'],
310 data : Roo.exampledata.states // from states.js
312 displayField:'state',
315 triggerAction: 'all',
316 emptyText:'Select a state...',
321 new Roo.form.DateField({
322 fieldLabel: 'Date of Birth',
329 fs.addButton('Save');
330 fs.addButton('Cancel');
332 fs.render('form-ct3');
335 * ================ Form 4 =======================
337 var form = new Roo.form.Form({
342 form.column({width:342, labelWidth:75}); // open column, without auto close
344 {legend:'Contact Information'},
345 new Roo.form.TextField({
346 fieldLabel: 'Full Name',
352 new Roo.form.TextField({
353 fieldLabel: 'Job Title',
358 new Roo.form.TextField({
359 fieldLabel: 'Company',
364 new Roo.form.TextArea({
365 fieldLabel: 'Address',
368 preventScrollbars:true,
369 value: '123 example drive'
373 {legend:'Phone Numbers'},
374 new Roo.form.TextField({
377 value: '(123) 456 789'
380 new Roo.form.TextField({
381 fieldLabel: 'Business',
385 new Roo.form.TextField({
386 fieldLabel: 'Mobile',
390 new Roo.form.TextField({
395 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
399 {width:202, style:'margin-left:10px', clear:true}
403 {id:'photo', legend:'Photo'}
408 {legend:'Options', hideLabels:true},
409 new Roo.form.Checkbox({
410 boxLabel:'RooJS v1.1.1',
414 new Roo.form.Checkbox({
415 boxLabel:'RooJS v2.0.0',
419 new Roo.form.Checkbox({
420 boxLabel:'RooScript',
427 form.end(); // close the column
430 form.applyIfToFields({
434 form.addButton('Save');
435 form.addButton('Cancel');
437 form.render('form-ct4');
439 // The form elements are standard HTML elements. By assigning an id (as we did above)
440 // we can manipulate them like any other element
441 var photo = Roo.get('photo');
442 var c = photo.createChild({
446 src: 'roojs_icon.jpg',
447 style:'margin-bottom:5px;'
454 form5 = new Roo.form.Form({
462 fieldLabel: 'A checkbox',
463 boxLabel:'RooJS v1.1.1',
470 xtype : 'DisplayField',
473 fieldLabel: 'Simple',
474 value : 'example text'
482 xtype: 'SimpleStore',
484 fields: ['abbr', 'state'],
485 data : Roo.exampledata.states // from states.js
487 displayField:'state',
490 triggerAction: 'all',
491 emptyText:'Select a state...',
497 Roo.MessageBox.alert("Alert", "Add Pressed");
501 Roo.MessageBox.alert("Alert", "Edit Pressed");
510 form5.render('form-ct5');