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({
102 new Roo.form.HtmlEditor.ToolbarStandard(),
103 new Roo.form.HtmlEditor.ToolbarContext()
107 fieldLabel:'Biography',
113 mform.addButton('Save');
114 mform.addButton('Cancel');
116 mform.render('form-ct2');
119 * ================ Form 3 =======================
121 var fs = new Roo.form.Form({
127 {legend:'Contact Information', style: 'width:320px;' },
128 new Roo.form.TextField({
129 fieldLabel: 'First Name',
134 new Roo.form.TextField({
135 fieldLabel: 'Last Name',
140 new Roo.form.TextField({
141 fieldLabel: 'Company',
146 new Roo.form.TextField({
153 new Roo.form.ComboBox({
156 store: new Roo.data.SimpleStore({
157 fields: ['abbr', 'state'],
158 data : Roo.exampledata.states // from states.js
160 displayField:'state',
163 triggerAction: 'all',
164 emptyText:'Select a state...',
169 new Roo.form.DateField({
170 fieldLabel: 'Date of Birth',
177 fs.addButton('Save');
178 fs.addButton('Cancel');
180 fs.render('form-ct3');
183 * ================ Form 4 =======================
185 var form = new Roo.form.Form({
190 form.column({width:342, labelWidth:75}); // open column, without auto close
192 {legend:'Contact Information'},
193 new Roo.form.TextField({
194 fieldLabel: 'Full Name',
200 new Roo.form.TextField({
201 fieldLabel: 'Job Title',
206 new Roo.form.TextField({
207 fieldLabel: 'Company',
212 new Roo.form.TextArea({
213 fieldLabel: 'Address',
216 preventScrollbars:true,
217 value: '123 example drive'
221 {legend:'Phone Numbers'},
222 new Roo.form.TextField({
225 value: '(123) 456 789'
228 new Roo.form.TextField({
229 fieldLabel: 'Business',
233 new Roo.form.TextField({
234 fieldLabel: 'Mobile',
238 new Roo.form.TextField({
243 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
247 {width:202, style:'margin-left:10px', clear:true}
251 {id:'photo', legend:'Photo'}
256 {legend:'Options', hideLabels:true},
257 new Roo.form.Checkbox({
258 boxLabel:'RooJS v1.1.1',
262 new Roo.form.Checkbox({
263 boxLabel:'RooJS v2.0.0',
267 new Roo.form.Checkbox({
268 boxLabel:'RooScript',
275 form.end(); // close the column
278 form.applyIfToFields({
282 form.addButton('Save');
283 form.addButton('Cancel');
285 form.render('form-ct4');
287 // The form elements are standard HTML elements. By assigning an id (as we did above)
288 // we can manipulate them like any other element
289 var photo = Roo.get('photo');
290 var c = photo.createChild({
294 src: 'roojs_icon.jpg',
295 style:'margin-bottom:5px;'
302 form5 = new Roo.form.Form({
310 fieldLabel: 'A checkbox',
311 boxLabel:'RooJS v1.1.1',
316 xtype : 'DisplayField',
319 fieldLabel: 'Example Label',
320 value : 'example text'
326 form5.render('form-ct5');