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',
48 new Roo.form.TextField({
49 fieldLabel: 'Password',
51 inputType: 'password',
55 new Roo.form.TextField({
61 new Roo.form.DayPicker({
62 fieldLabel: 'Pick a day',
66 new Roo.form.Signature({
67 fieldLabel: 'Signature',
73 simple.addButton('Save');
74 simple.addButton('Cancel');
76 simple.render('form-ct');
80 * ================ Form 2 =======================
82 mform = new Roo.form.Form({
89 width: 500, // precise column sizes or percentages or straight CSS
92 xtype : 'ComboBoxArray',
94 fieldLabel: 'Multi select test',
96 hiddenName: 'country',
102 displayField : 'state',
104 name : 'countryNames',
105 hiddenName : 'country',
110 xtype : 'SimpleStore',
112 fields: ['abbr', 'state'],
113 data : Roo.exampledata.states // from states.js
121 triggerAction: 'all',
122 emptyText:'Select a state...',
137 width: 500, // precise column sizes or percentages or straight CSS
140 xtype : 'ComboBoxArray',
142 fieldLabel: 'Multi select test',
145 name: 'countrylist_names',
146 hiddenName: 'countrylist',
152 displayField : 'title',
154 // thes are not really needed as parent overwrites them!?
155 name : 'country_name',
156 hiddenName : 'country',
171 xtype : 'ScriptTagProxy',
172 url: 'http://www.roojs.com/forum/topics-remote.php'
176 xtype : 'JsonReader',
178 totalProperty: 'totalCount',
181 {name: 'title', mapping: 'topic_title'},
182 {name: 'topicId', mapping: 'topic_id'},
183 {name: 'author', mapping: 'author'},
184 {name: 'lastPost', mapping: 'post_time', type: 'date', dateFormat: 'timestamp'},
185 {name: 'excerpt', mapping: 'post_text'}
195 triggerAction: 'all',
196 emptyText:'Select a state...',
215 width: 272, // precise column sizes or percentages or straight CSS
219 fieldLabel: 'First Name',
225 fieldLabel: 'Company',
235 style:'margin-left:10px',
240 fieldLabel: 'Last Name',
260 xtype : 'HtmlEditor',
262 fieldLabel:'Biography',
265 resizable: 's', /// where the handles should got..
266 toolbars : [ 'ToolbarStandard', 'ToolbarContext' ]
273 mform.addButton('Save');
274 mform.addButton('Cancel');
277 mform.render('form-ct2');
280 countryNames : 'Alaska,Louisana',
281 countrylist : 'AG,AZ',
282 countrylist_names : 'Antigua and Barbuda,Azerbaijan'
285 * ================ Form 3 =======================
287 var fs = new Roo.form.Form({
293 {legend:'Contact Information', style: 'width:320px;' },
294 new Roo.form.TextField({
295 fieldLabel: 'First Name',
300 new Roo.form.TextField({
301 fieldLabel: 'Last Name',
306 new Roo.form.TextField({
307 fieldLabel: 'Company',
312 new Roo.form.TextField({
319 new Roo.form.ComboBox({
322 store: new Roo.data.SimpleStore({
323 fields: ['abbr', 'state'],
324 data : Roo.exampledata.states // from states.js
326 displayField:'state',
329 triggerAction: 'all',
330 emptyText:'Select a state...',
335 new Roo.form.DateField({
336 fieldLabel: 'Date of Birth',
341 new Roo.form.MonthField({
342 fieldLabel: 'Date of Month',
349 fs.addButton('Save');
350 fs.addButton('Cancel');
352 fs.render('form-ct3');
355 * ================ Form 4 =======================
357 var form = new Roo.form.Form({
362 form.column({width:342, labelWidth:75}); // open column, without auto close
364 {legend:'Contact Information'},
365 new Roo.form.TextField({
366 fieldLabel: 'Full Name',
372 new Roo.form.TextField({
373 fieldLabel: 'Job Title',
378 new Roo.form.TextField({
379 fieldLabel: 'Company',
384 new Roo.form.TextArea({
385 fieldLabel: 'Address',
388 preventScrollbars:true,
389 value: '123 example drive'
393 {legend:'Phone Numbers'},
394 new Roo.form.TextField({
397 value: '(123) 456 789'
400 new Roo.form.TextField({
401 fieldLabel: 'Business',
405 new Roo.form.TextField({
406 fieldLabel: 'Mobile',
410 new Roo.form.TextField({
415 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
419 {width:202, style:'margin-left:10px', clear:true}
423 {id:'photo', legend:'Photo'}
428 {legend:'Options', hideLabels:true},
429 new Roo.form.Checkbox({
430 boxLabel:'RooJS v1.1.1',
434 new Roo.form.Checkbox({
435 boxLabel:'RooJS v2.0.0',
439 new Roo.form.Checkbox({
440 boxLabel:'RooScript',
447 form.end(); // close the column
450 form.applyIfToFields({
454 form.addButton('Save');
455 form.addButton('Cancel');
457 form.render('form-ct4');
459 // The form elements are standard HTML elements. By assigning an id (as we did above)
460 // we can manipulate them like any other element
461 var photo = Roo.get('photo');
462 var c = photo.createChild({
466 src: 'roojs_icon.jpg',
467 style:'margin-bottom:5px;'
474 form5 = new Roo.form.Form({
482 fieldLabel: 'A checkbox',
483 boxLabel:'RooJS v1.1.1',
490 xtype : 'DisplayField',
493 fieldLabel: 'Simple',
494 value : 'example text'
502 xtype: 'SimpleStore',
504 fields: ['abbr', 'state'],
505 data : Roo.exampledata.states // from states.js
507 displayField:'state',
510 triggerAction: 'all',
511 emptyText:'Select a state...',
517 Roo.MessageBox.alert("Alert", "Add Pressed");
521 Roo.MessageBox.alert("Alert", "Edit Pressed");
530 form5.render('form-ct5');
533 form6 = new Roo.form.Form({
541 fieldLabel: 'test time picker',
545 xtype: 'DateDisplay',
547 fieldLabel: 'test date picker',
555 form6.render('form-ct6');