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">
14 Roo.onReady(function(){
18 // turn on validation errors beside the field globally
19 Roo.form.Field.prototype.msgTarget = 'side';
22 * ================ Simple form =======================
24 simple = new Roo.form.Form({
25 labelWidth: 75, // label settings here cascade unless overridden
29 new Roo.form.TextField({
30 fieldLabel: 'First Name',
36 new Roo.form.TextField({
37 fieldLabel: 'Last Name',
42 new Roo.form.TextField({
43 fieldLabel: 'Company',
48 new Roo.form.TextField({
54 new Roo.form.DayPicker({
55 fieldLabel: 'Pick a day',
61 simple.addButton('Save');
62 simple.addButton('Cancel');
64 simple.render('form-ct');
68 * ================ Form 2 =======================
70 mform = new Roo.form.Form({
77 width: 500, // precise column sizes or percentages or straight CSS
80 xtype : 'ComboBoxArray',
82 fieldLabel: 'Multi select test',
84 hiddenName: 'countryNames',
92 xtype : 'SimpleStore',
94 fields: ['abbr', 'state'],
95 data : Roo.exampledata.states // from states.js
101 triggerAction: 'all',
102 emptyText:'Select a state...',
116 width: 272, // precise column sizes or percentages or straight CSS
120 fieldLabel: 'First Name',
126 fieldLabel: 'Company',
136 style:'margin-left:10px',
141 fieldLabel: 'Last Name',
161 xtype : 'HtmlEditor',
163 fieldLabel:'Biography',
166 resizable: 's' /// where the handles should got..
173 mform.addButton('Save');
174 mform.addButton('Cancel');
177 mform.render('form-ct2');
180 countryNames : 'Hong Kong, Singapore'
185 * ================ Form 3 =======================
187 var fs = new Roo.form.Form({
193 {legend:'Contact Information', style: 'width:320px;' },
194 new Roo.form.TextField({
195 fieldLabel: 'First Name',
200 new Roo.form.TextField({
201 fieldLabel: 'Last Name',
206 new Roo.form.TextField({
207 fieldLabel: 'Company',
212 new Roo.form.TextField({
219 new Roo.form.ComboBox({
222 store: new Roo.data.SimpleStore({
223 fields: ['abbr', 'state'],
224 data : Roo.exampledata.states // from states.js
226 displayField:'state',
229 triggerAction: 'all',
230 emptyText:'Select a state...',
235 new Roo.form.DateField({
236 fieldLabel: 'Date of Birth',
243 fs.addButton('Save');
244 fs.addButton('Cancel');
246 fs.render('form-ct3');
249 * ================ Form 4 =======================
251 var form = new Roo.form.Form({
256 form.column({width:342, labelWidth:75}); // open column, without auto close
258 {legend:'Contact Information'},
259 new Roo.form.TextField({
260 fieldLabel: 'Full Name',
266 new Roo.form.TextField({
267 fieldLabel: 'Job Title',
272 new Roo.form.TextField({
273 fieldLabel: 'Company',
278 new Roo.form.TextArea({
279 fieldLabel: 'Address',
282 preventScrollbars:true,
283 value: '123 example drive'
287 {legend:'Phone Numbers'},
288 new Roo.form.TextField({
291 value: '(123) 456 789'
294 new Roo.form.TextField({
295 fieldLabel: 'Business',
299 new Roo.form.TextField({
300 fieldLabel: 'Mobile',
304 new Roo.form.TextField({
309 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
313 {width:202, style:'margin-left:10px', clear:true}
317 {id:'photo', legend:'Photo'}
322 {legend:'Options', hideLabels:true},
323 new Roo.form.Checkbox({
324 boxLabel:'RooJS v1.1.1',
328 new Roo.form.Checkbox({
329 boxLabel:'RooJS v2.0.0',
333 new Roo.form.Checkbox({
334 boxLabel:'RooScript',
341 form.end(); // close the column
344 form.applyIfToFields({
348 form.addButton('Save');
349 form.addButton('Cancel');
351 form.render('form-ct4');
353 // The form elements are standard HTML elements. By assigning an id (as we did above)
354 // we can manipulate them like any other element
355 var photo = Roo.get('photo');
356 var c = photo.createChild({
360 src: 'roojs_icon.jpg',
361 style:'margin-bottom:5px;'
368 form5 = new Roo.form.Form({
376 fieldLabel: 'A checkbox',
377 boxLabel:'RooJS v1.1.1',
384 xtype : 'DisplayField',
387 fieldLabel: 'Simple',
388 value : 'example text'
396 xtype: 'SimpleStore',
398 fields: ['abbr', 'state'],
399 data : Roo.exampledata.states // from states.js
401 displayField:'state',
404 triggerAction: 'all',
405 emptyText:'Select a state...',
411 Roo.MessageBox.alert("Alert", "Add Pressed");
415 Roo.MessageBox.alert("Alert", "Edit Pressed");
424 form5.render('form-ct5');