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: 'countryNames',
90 displayField : 'state',
92 name : 'countryNames',
93 hiddenName : 'country',
98 xtype : 'SimpleStore',
100 fields: ['abbr', 'state'],
101 data : Roo.exampledata.states // from states.js
109 triggerAction: 'all',
110 emptyText:'Select a state...',
124 width: 272, // precise column sizes or percentages or straight CSS
128 fieldLabel: 'First Name',
134 fieldLabel: 'Company',
144 style:'margin-left:10px',
149 fieldLabel: 'Last Name',
169 xtype : 'HtmlEditor',
171 fieldLabel:'Biography',
174 resizable: 's' /// where the handles should got..
181 mform.addButton('Save');
182 mform.addButton('Cancel');
185 mform.render('form-ct2');
188 countryNames : 'Hong Kong, Singapore'
193 * ================ Form 3 =======================
195 var fs = new Roo.form.Form({
201 {legend:'Contact Information', style: 'width:320px;' },
202 new Roo.form.TextField({
203 fieldLabel: 'First Name',
208 new Roo.form.TextField({
209 fieldLabel: 'Last Name',
214 new Roo.form.TextField({
215 fieldLabel: 'Company',
220 new Roo.form.TextField({
227 new Roo.form.ComboBox({
230 store: new Roo.data.SimpleStore({
231 fields: ['abbr', 'state'],
232 data : Roo.exampledata.states // from states.js
234 displayField:'state',
237 triggerAction: 'all',
238 emptyText:'Select a state...',
243 new Roo.form.DateField({
244 fieldLabel: 'Date of Birth',
251 fs.addButton('Save');
252 fs.addButton('Cancel');
254 fs.render('form-ct3');
257 * ================ Form 4 =======================
259 var form = new Roo.form.Form({
264 form.column({width:342, labelWidth:75}); // open column, without auto close
266 {legend:'Contact Information'},
267 new Roo.form.TextField({
268 fieldLabel: 'Full Name',
274 new Roo.form.TextField({
275 fieldLabel: 'Job Title',
280 new Roo.form.TextField({
281 fieldLabel: 'Company',
286 new Roo.form.TextArea({
287 fieldLabel: 'Address',
290 preventScrollbars:true,
291 value: '123 example drive'
295 {legend:'Phone Numbers'},
296 new Roo.form.TextField({
299 value: '(123) 456 789'
302 new Roo.form.TextField({
303 fieldLabel: 'Business',
307 new Roo.form.TextField({
308 fieldLabel: 'Mobile',
312 new Roo.form.TextField({
317 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
321 {width:202, style:'margin-left:10px', clear:true}
325 {id:'photo', legend:'Photo'}
330 {legend:'Options', hideLabels:true},
331 new Roo.form.Checkbox({
332 boxLabel:'RooJS v1.1.1',
336 new Roo.form.Checkbox({
337 boxLabel:'RooJS v2.0.0',
341 new Roo.form.Checkbox({
342 boxLabel:'RooScript',
349 form.end(); // close the column
352 form.applyIfToFields({
356 form.addButton('Save');
357 form.addButton('Cancel');
359 form.render('form-ct4');
361 // The form elements are standard HTML elements. By assigning an id (as we did above)
362 // we can manipulate them like any other element
363 var photo = Roo.get('photo');
364 var c = photo.createChild({
368 src: 'roojs_icon.jpg',
369 style:'margin-bottom:5px;'
376 form5 = new Roo.form.Form({
384 fieldLabel: 'A checkbox',
385 boxLabel:'RooJS v1.1.1',
392 xtype : 'DisplayField',
395 fieldLabel: 'Simple',
396 value : 'example text'
404 xtype: 'SimpleStore',
406 fields: ['abbr', 'state'],
407 data : Roo.exampledata.states // from states.js
409 displayField:'state',
412 triggerAction: 'all',
413 emptyText:'Select a state...',
419 Roo.MessageBox.alert("Alert", "Add Pressed");
423 Roo.MessageBox.alert("Alert", "Edit Pressed");
432 form5.render('form-ct5');