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',
93 xtype : 'SimpleStore',
95 fields: ['abbr', 'state'],
96 data : Roo.exampledata.states // from states.js
102 triggerAction: 'all',
103 emptyText:'Select a state...',
117 width: 272, // precise column sizes or percentages or straight CSS
121 fieldLabel: 'First Name',
127 fieldLabel: 'Company',
137 style:'margin-left:10px',
142 fieldLabel: 'Last Name',
162 xtype : 'HtmlEditor',
164 fieldLabel:'Biography',
167 resizable: 's' /// where the handles should got..
174 mform.addButton('Save');
175 mform.addButton('Cancel');
178 mform.render('form-ct2');
181 countryNames : 'Hong Kong, Singapore'
186 * ================ Form 3 =======================
188 var fs = new Roo.form.Form({
194 {legend:'Contact Information', style: 'width:320px;' },
195 new Roo.form.TextField({
196 fieldLabel: 'First Name',
201 new Roo.form.TextField({
202 fieldLabel: 'Last Name',
207 new Roo.form.TextField({
208 fieldLabel: 'Company',
213 new Roo.form.TextField({
220 new Roo.form.ComboBox({
223 store: new Roo.data.SimpleStore({
224 fields: ['abbr', 'state'],
225 data : Roo.exampledata.states // from states.js
227 displayField:'state',
230 triggerAction: 'all',
231 emptyText:'Select a state...',
236 new Roo.form.DateField({
237 fieldLabel: 'Date of Birth',
244 fs.addButton('Save');
245 fs.addButton('Cancel');
247 fs.render('form-ct3');
250 * ================ Form 4 =======================
252 var form = new Roo.form.Form({
257 form.column({width:342, labelWidth:75}); // open column, without auto close
259 {legend:'Contact Information'},
260 new Roo.form.TextField({
261 fieldLabel: 'Full Name',
267 new Roo.form.TextField({
268 fieldLabel: 'Job Title',
273 new Roo.form.TextField({
274 fieldLabel: 'Company',
279 new Roo.form.TextArea({
280 fieldLabel: 'Address',
283 preventScrollbars:true,
284 value: '123 example drive'
288 {legend:'Phone Numbers'},
289 new Roo.form.TextField({
292 value: '(123) 456 789'
295 new Roo.form.TextField({
296 fieldLabel: 'Business',
300 new Roo.form.TextField({
301 fieldLabel: 'Mobile',
305 new Roo.form.TextField({
310 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
314 {width:202, style:'margin-left:10px', clear:true}
318 {id:'photo', legend:'Photo'}
323 {legend:'Options', hideLabels:true},
324 new Roo.form.Checkbox({
325 boxLabel:'RooJS v1.1.1',
329 new Roo.form.Checkbox({
330 boxLabel:'RooJS v2.0.0',
334 new Roo.form.Checkbox({
335 boxLabel:'RooScript',
342 form.end(); // close the column
345 form.applyIfToFields({
349 form.addButton('Save');
350 form.addButton('Cancel');
352 form.render('form-ct4');
354 // The form elements are standard HTML elements. By assigning an id (as we did above)
355 // we can manipulate them like any other element
356 var photo = Roo.get('photo');
357 var c = photo.createChild({
361 src: 'roojs_icon.jpg',
362 style:'margin-bottom:5px;'
369 form5 = new Roo.form.Form({
377 fieldLabel: 'A checkbox',
378 boxLabel:'RooJS v1.1.1',
385 xtype : 'DisplayField',
388 fieldLabel: 'Simple',
389 value : 'example text'
397 xtype: 'SimpleStore',
399 fields: ['abbr', 'state'],
400 data : Roo.exampledata.states // from states.js
402 displayField:'state',
405 triggerAction: 'all',
406 emptyText:'Select a state...',
412 Roo.MessageBox.alert("Alert", "Add Pressed");
416 Roo.MessageBox.alert("Alert", "Edit Pressed");
425 form5.render('form-ct5');