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',
134 name: 'countrylist_names',
135 hiddenName: 'countrylist',
141 displayField : 'title',
143 // thes are not really needed as parent overwrites them!?
144 name : 'country_name',
145 hiddenName : 'country',
160 xtype : 'ScriptTagProxy',
161 url: 'http://www.roojs.com/forum/topics-remote.php'
165 xtype : 'JsonReader',
167 totalProperty: 'totalCount',
170 {name: 'title', mapping: 'topic_title'},
171 {name: 'topicId', mapping: 'topic_id'},
172 {name: 'author', mapping: 'author'},
173 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
174 {name: 'excerpt', mapping: 'post_text'}
184 triggerAction: 'all',
185 emptyText:'Select a state...',
204 width: 272, // precise column sizes or percentages or straight CSS
208 fieldLabel: 'First Name',
214 fieldLabel: 'Company',
224 style:'margin-left:10px',
229 fieldLabel: 'Last Name',
249 xtype : 'HtmlEditor',
251 fieldLabel:'Biography',
254 resizable: 's' /// where the handles should got..
261 mform.addButton('Save');
262 mform.addButton('Cancel');
265 mform.render('form-ct2');
268 countryNames : 'Alaska,Louisana',
269 countrylist : 'AG,AZ',
270 countrylist_names : 'Antigua and Barbuda,Azerbaijan'
273 * ================ Form 3 =======================
275 var fs = new Roo.form.Form({
281 {legend:'Contact Information', style: 'width:320px;' },
282 new Roo.form.TextField({
283 fieldLabel: 'First Name',
288 new Roo.form.TextField({
289 fieldLabel: 'Last Name',
294 new Roo.form.TextField({
295 fieldLabel: 'Company',
300 new Roo.form.TextField({
307 new Roo.form.ComboBox({
310 store: new Roo.data.SimpleStore({
311 fields: ['abbr', 'state'],
312 data : Roo.exampledata.states // from states.js
314 displayField:'state',
317 triggerAction: 'all',
318 emptyText:'Select a state...',
323 new Roo.form.DateField({
324 fieldLabel: 'Date of Birth',
331 fs.addButton('Save');
332 fs.addButton('Cancel');
334 fs.render('form-ct3');
337 * ================ Form 4 =======================
339 var form = new Roo.form.Form({
344 form.column({width:342, labelWidth:75}); // open column, without auto close
346 {legend:'Contact Information'},
347 new Roo.form.TextField({
348 fieldLabel: 'Full Name',
354 new Roo.form.TextField({
355 fieldLabel: 'Job Title',
360 new Roo.form.TextField({
361 fieldLabel: 'Company',
366 new Roo.form.TextArea({
367 fieldLabel: 'Address',
370 preventScrollbars:true,
371 value: '123 example drive'
375 {legend:'Phone Numbers'},
376 new Roo.form.TextField({
379 value: '(123) 456 789'
382 new Roo.form.TextField({
383 fieldLabel: 'Business',
387 new Roo.form.TextField({
388 fieldLabel: 'Mobile',
392 new Roo.form.TextField({
397 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
401 {width:202, style:'margin-left:10px', clear:true}
405 {id:'photo', legend:'Photo'}
410 {legend:'Options', hideLabels:true},
411 new Roo.form.Checkbox({
412 boxLabel:'RooJS v1.1.1',
416 new Roo.form.Checkbox({
417 boxLabel:'RooJS v2.0.0',
421 new Roo.form.Checkbox({
422 boxLabel:'RooScript',
429 form.end(); // close the column
432 form.applyIfToFields({
436 form.addButton('Save');
437 form.addButton('Cancel');
439 form.render('form-ct4');
441 // The form elements are standard HTML elements. By assigning an id (as we did above)
442 // we can manipulate them like any other element
443 var photo = Roo.get('photo');
444 var c = photo.createChild({
448 src: 'roojs_icon.jpg',
449 style:'margin-bottom:5px;'
456 form5 = new Roo.form.Form({
464 fieldLabel: 'A checkbox',
465 boxLabel:'RooJS v1.1.1',
472 xtype : 'DisplayField',
475 fieldLabel: 'Simple',
476 value : 'example text'
484 xtype: 'SimpleStore',
486 fields: ['abbr', 'state'],
487 data : Roo.exampledata.states // from states.js
489 displayField:'state',
492 triggerAction: 'all',
493 emptyText:'Select a state...',
499 Roo.MessageBox.alert("Alert", "Add Pressed");
503 Roo.MessageBox.alert("Alert", "Edit Pressed");
512 form5.render('form-ct5');
515 form6 = new Roo.form.Form({
523 fieldLabel: 'test time picker',
531 form6.render('form-ct6');