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({
55 simple.addButton('Save');
56 simple.addButton('Cancel');
58 simple.render('form-ct');
62 * ================ Form 2 =======================
64 mform = new Roo.form.Form({
69 {width:282}, // precise column sizes or percentages or straight CSS
70 new Roo.form.TextField({
71 fieldLabel: 'First Name',
76 new Roo.form.TextField({
77 fieldLabel: 'Company',
84 {width:272, style:'margin-left:10px', clear:true}, // apply custom css, clear:true means it is the last column
85 new Roo.form.TextField({
86 fieldLabel: 'Last Name',
91 new Roo.form.TextField({
100 new Roo.form.HtmlEditor({
104 fieldLabel:'Biography',
110 mform.addButton('Save');
111 mform.addButton('Cancel');
113 mform.render('form-ct2');
116 * ================ Form 3 =======================
118 var fs = new Roo.form.Form({
124 {legend:'Contact Information', style: 'width:320px;' },
125 new Roo.form.TextField({
126 fieldLabel: 'First Name',
131 new Roo.form.TextField({
132 fieldLabel: 'Last Name',
137 new Roo.form.TextField({
138 fieldLabel: 'Company',
143 new Roo.form.TextField({
150 new Roo.form.ComboBox({
153 store: new Roo.data.SimpleStore({
154 fields: ['abbr', 'state'],
155 data : Roo.exampledata.states // from states.js
157 displayField:'state',
160 triggerAction: 'all',
161 emptyText:'Select a state...',
166 new Roo.form.DateField({
167 fieldLabel: 'Date of Birth',
174 fs.addButton('Save');
175 fs.addButton('Cancel');
177 fs.render('form-ct3');
180 * ================ Form 4 =======================
182 var form = new Roo.form.Form({
187 form.column({width:342, labelWidth:75}); // open column, without auto close
189 {legend:'Contact Information'},
190 new Roo.form.TextField({
191 fieldLabel: 'Full Name',
197 new Roo.form.TextField({
198 fieldLabel: 'Job Title',
203 new Roo.form.TextField({
204 fieldLabel: 'Company',
209 new Roo.form.TextArea({
210 fieldLabel: 'Address',
213 preventScrollbars:true,
214 value: '123 example drive'
218 {legend:'Phone Numbers'},
219 new Roo.form.TextField({
222 value: '(123) 456 789'
225 new Roo.form.TextField({
226 fieldLabel: 'Business',
230 new Roo.form.TextField({
231 fieldLabel: 'Mobile',
235 new Roo.form.TextField({
240 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
244 {width:202, style:'margin-left:10px', clear:true}
248 {id:'photo', legend:'Photo'}
253 {legend:'Options', hideLabels:true},
254 new Roo.form.Checkbox({
255 boxLabel:'RooJS v1.1.1',
259 new Roo.form.Checkbox({
260 boxLabel:'RooJS v2.0.0',
264 new Roo.form.Checkbox({
265 boxLabel:'RooScript',
272 form.end(); // close the column
275 form.applyIfToFields({
279 form.addButton('Save');
280 form.addButton('Cancel');
282 form.render('form-ct4');
284 // The form elements are standard HTML elements. By assigning an id (as we did above)
285 // we can manipulate them like any other element
286 var photo = Roo.get('photo');
287 var c = photo.createChild({
291 src: 'roojs_icon.jpg',
292 style:'margin-bottom:5px;'
299 form5 = new Roo.form.Form({
307 fieldLabel: 'A checkbox',
308 boxLabel:'RooJS v1.1.1',
313 xtype : 'DisplayField',
316 fieldLabel: 'Simple',
317 value : 'example text'
325 xtype: 'SimpleStore',
327 fields: ['abbr', 'state'],
328 data : Roo.exampledata.states // from states.js
330 displayField:'state',
333 triggerAction: 'all',
334 emptyText:'Select a state...',
340 Roo.MessageBox.alert("Alert", "Add Pressed");
344 Roo.MessageBox.alert("Alert", "Edit Pressed");
353 form5.render('form-ct5');