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">
13 Roo.onReady(function(){
17 // turn on validation errors beside the field globally
18 Roo.form.Field.prototype.msgTarget = 'side';
21 * ================ Simple form =======================
23 var simple = new Roo.form.Form({
24 labelWidth: 75, // label settings here cascade unless overridden
28 new Roo.form.TextField({
29 fieldLabel: 'First Name',
35 new Roo.form.TextField({
36 fieldLabel: 'Last Name',
41 new Roo.form.TextField({
42 fieldLabel: 'Company',
47 new Roo.form.TextField({
53 new Roo.form.DayPicker({
54 fieldLabel: 'Pick a day',
60 simple.addButton('Save');
61 simple.addButton('Cancel');
63 simple.render('form-ct');
67 * ================ Form 2 =======================
69 mform = new Roo.form.Form({
75 width: 272, // precise column sizes or percentages or straight CSS
79 fieldLabel: 'First Name',
85 fieldLabel: 'Company',
95 style:'margin-left:10px',
100 fieldLabel: 'Last Name',
120 xtype : 'HtmlEditor',
122 fieldLabel:'Biography',
131 mform.addButton('Save');
132 mform.addButton('Cancel');
135 mform.render('form-ct2');
138 * ================ Form 3 =======================
140 var fs = new Roo.form.Form({
146 {legend:'Contact Information', style: 'width:320px;' },
147 new Roo.form.TextField({
148 fieldLabel: 'First Name',
153 new Roo.form.TextField({
154 fieldLabel: 'Last Name',
159 new Roo.form.TextField({
160 fieldLabel: 'Company',
165 new Roo.form.TextField({
172 new Roo.form.ComboBox({
175 store: new Roo.data.SimpleStore({
176 fields: ['abbr', 'state'],
177 data : Roo.exampledata.states // from states.js
179 displayField:'state',
182 triggerAction: 'all',
183 emptyText:'Select a state...',
188 new Roo.form.DateField({
189 fieldLabel: 'Date of Birth',
196 fs.addButton('Save');
197 fs.addButton('Cancel');
199 fs.render('form-ct3');
202 * ================ Form 4 =======================
204 var form = new Roo.form.Form({
209 form.column({width:342, labelWidth:75}); // open column, without auto close
211 {legend:'Contact Information'},
212 new Roo.form.TextField({
213 fieldLabel: 'Full Name',
219 new Roo.form.TextField({
220 fieldLabel: 'Job Title',
225 new Roo.form.TextField({
226 fieldLabel: 'Company',
231 new Roo.form.TextArea({
232 fieldLabel: 'Address',
235 preventScrollbars:true,
236 value: '123 example drive'
240 {legend:'Phone Numbers'},
241 new Roo.form.TextField({
244 value: '(123) 456 789'
247 new Roo.form.TextField({
248 fieldLabel: 'Business',
252 new Roo.form.TextField({
253 fieldLabel: 'Mobile',
257 new Roo.form.TextField({
262 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
266 {width:202, style:'margin-left:10px', clear:true}
270 {id:'photo', legend:'Photo'}
275 {legend:'Options', hideLabels:true},
276 new Roo.form.Checkbox({
277 boxLabel:'RooJS v1.1.1',
281 new Roo.form.Checkbox({
282 boxLabel:'RooJS v2.0.0',
286 new Roo.form.Checkbox({
287 boxLabel:'RooScript',
294 form.end(); // close the column
297 form.applyIfToFields({
301 form.addButton('Save');
302 form.addButton('Cancel');
304 form.render('form-ct4');
306 // The form elements are standard HTML elements. By assigning an id (as we did above)
307 // we can manipulate them like any other element
308 var photo = Roo.get('photo');
309 var c = photo.createChild({
313 src: 'roojs_icon.jpg',
314 style:'margin-bottom:5px;'
321 form5 = new Roo.form.Form({
329 fieldLabel: 'A checkbox',
330 boxLabel:'RooJS v1.1.1',
337 xtype : 'DisplayField',
340 fieldLabel: 'Simple',
341 value : 'example text'
349 xtype: 'SimpleStore',
351 fields: ['abbr', 'state'],
352 data : Roo.exampledata.states // from states.js
354 displayField:'state',
357 triggerAction: 'all',
358 emptyText:'Select a state...',
364 Roo.MessageBox.alert("Alert", "Add Pressed");
368 Roo.MessageBox.alert("Alert", "Edit Pressed");
377 form5.render('form-ct5');