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',
162 xtype : 'ScriptTagProxy',
163 url: 'http://www.roojs.com/forum/topics-remote.php'
167 xtype : 'JsonReader',
169 totalProperty: 'totalCount',
172 {name: 'title', mapping: 'topic_title'},
173 {name: 'topicId', mapping: 'topic_id'},
174 {name: 'author', mapping: 'author'},
175 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
176 {name: 'excerpt', mapping: 'post_text'}
186 triggerAction: 'all',
187 emptyText:'Select a state...',
206 width: 272, // precise column sizes or percentages or straight CSS
210 fieldLabel: 'First Name',
216 fieldLabel: 'Company',
226 style:'margin-left:10px',
231 fieldLabel: 'Last Name',
251 xtype : 'HtmlEditor',
253 fieldLabel:'Biography',
256 resizable: 's' /// where the handles should got..
263 mform.addButton('Save');
264 mform.addButton('Cancel');
267 mform.render('form-ct2');
270 countryNames : 'Alaska,Louisana'
275 * ================ Form 3 =======================
277 var fs = new Roo.form.Form({
283 {legend:'Contact Information', style: 'width:320px;' },
284 new Roo.form.TextField({
285 fieldLabel: 'First Name',
290 new Roo.form.TextField({
291 fieldLabel: 'Last Name',
296 new Roo.form.TextField({
297 fieldLabel: 'Company',
302 new Roo.form.TextField({
309 new Roo.form.ComboBox({
312 store: new Roo.data.SimpleStore({
313 fields: ['abbr', 'state'],
314 data : Roo.exampledata.states // from states.js
316 displayField:'state',
319 triggerAction: 'all',
320 emptyText:'Select a state...',
325 new Roo.form.DateField({
326 fieldLabel: 'Date of Birth',
333 fs.addButton('Save');
334 fs.addButton('Cancel');
336 fs.render('form-ct3');
339 * ================ Form 4 =======================
341 var form = new Roo.form.Form({
346 form.column({width:342, labelWidth:75}); // open column, without auto close
348 {legend:'Contact Information'},
349 new Roo.form.TextField({
350 fieldLabel: 'Full Name',
356 new Roo.form.TextField({
357 fieldLabel: 'Job Title',
362 new Roo.form.TextField({
363 fieldLabel: 'Company',
368 new Roo.form.TextArea({
369 fieldLabel: 'Address',
372 preventScrollbars:true,
373 value: '123 example drive'
377 {legend:'Phone Numbers'},
378 new Roo.form.TextField({
381 value: '(123) 456 789'
384 new Roo.form.TextField({
385 fieldLabel: 'Business',
389 new Roo.form.TextField({
390 fieldLabel: 'Mobile',
394 new Roo.form.TextField({
399 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
403 {width:202, style:'margin-left:10px', clear:true}
407 {id:'photo', legend:'Photo'}
412 {legend:'Options', hideLabels:true},
413 new Roo.form.Checkbox({
414 boxLabel:'RooJS v1.1.1',
418 new Roo.form.Checkbox({
419 boxLabel:'RooJS v2.0.0',
423 new Roo.form.Checkbox({
424 boxLabel:'RooScript',
431 form.end(); // close the column
434 form.applyIfToFields({
438 form.addButton('Save');
439 form.addButton('Cancel');
441 form.render('form-ct4');
443 // The form elements are standard HTML elements. By assigning an id (as we did above)
444 // we can manipulate them like any other element
445 var photo = Roo.get('photo');
446 var c = photo.createChild({
450 src: 'roojs_icon.jpg',
451 style:'margin-bottom:5px;'
458 form5 = new Roo.form.Form({
466 fieldLabel: 'A checkbox',
467 boxLabel:'RooJS v1.1.1',
474 xtype : 'DisplayField',
477 fieldLabel: 'Simple',
478 value : 'example text'
486 xtype: 'SimpleStore',
488 fields: ['abbr', 'state'],
489 data : Roo.exampledata.states // from states.js
491 displayField:'state',
494 triggerAction: 'all',
495 emptyText:'Select a state...',
501 Roo.MessageBox.alert("Alert", "Add Pressed");
505 Roo.MessageBox.alert("Alert", "Edit Pressed");
514 form5.render('form-ct5');