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({
70 width: 600, // precise column sizes or percentages or straight CSS
74 fieldLabel: 'First Name',
80 fieldLabel: 'Company',
90 style:'margin-left:10px',
95 fieldLabel: 'Last Name',
117 fieldLabel:'Biography',
138 mform.render('form-ct2');
141 * ================ Form 3 =======================
143 var fs = new Roo.form.Form({
149 {legend:'Contact Information', style: 'width:320px;' },
150 new Roo.form.TextField({
151 fieldLabel: 'First Name',
156 new Roo.form.TextField({
157 fieldLabel: 'Last Name',
162 new Roo.form.TextField({
163 fieldLabel: 'Company',
168 new Roo.form.TextField({
175 new Roo.form.ComboBox({
178 store: new Roo.data.SimpleStore({
179 fields: ['abbr', 'state'],
180 data : Roo.exampledata.states // from states.js
182 displayField:'state',
185 triggerAction: 'all',
186 emptyText:'Select a state...',
191 new Roo.form.DateField({
192 fieldLabel: 'Date of Birth',
199 fs.addButton('Save');
200 fs.addButton('Cancel');
202 fs.render('form-ct3');
205 * ================ Form 4 =======================
207 var form = new Roo.form.Form({
212 form.column({width:342, labelWidth:75}); // open column, without auto close
214 {legend:'Contact Information'},
215 new Roo.form.TextField({
216 fieldLabel: 'Full Name',
222 new Roo.form.TextField({
223 fieldLabel: 'Job Title',
228 new Roo.form.TextField({
229 fieldLabel: 'Company',
234 new Roo.form.TextArea({
235 fieldLabel: 'Address',
238 preventScrollbars:true,
239 value: '123 example drive'
243 {legend:'Phone Numbers'},
244 new Roo.form.TextField({
247 value: '(123) 456 789'
250 new Roo.form.TextField({
251 fieldLabel: 'Business',
255 new Roo.form.TextField({
256 fieldLabel: 'Mobile',
260 new Roo.form.TextField({
265 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
269 {width:202, style:'margin-left:10px', clear:true}
273 {id:'photo', legend:'Photo'}
278 {legend:'Options', hideLabels:true},
279 new Roo.form.Checkbox({
280 boxLabel:'RooJS v1.1.1',
284 new Roo.form.Checkbox({
285 boxLabel:'RooJS v2.0.0',
289 new Roo.form.Checkbox({
290 boxLabel:'RooScript',
297 form.end(); // close the column
300 form.applyIfToFields({
304 form.addButton('Save');
305 form.addButton('Cancel');
307 form.render('form-ct4');
309 // The form elements are standard HTML elements. By assigning an id (as we did above)
310 // we can manipulate them like any other element
311 var photo = Roo.get('photo');
312 var c = photo.createChild({
316 src: 'roojs_icon.jpg',
317 style:'margin-bottom:5px;'
324 form5 = new Roo.form.Form({
332 fieldLabel: 'A checkbox',
333 boxLabel:'RooJS v1.1.1',
338 xtype : 'DisplayField',
341 fieldLabel: 'Simple',
342 value : 'example text'
350 xtype: 'SimpleStore',
352 fields: ['abbr', 'state'],
353 data : Roo.exampledata.states // from states.js
355 displayField:'state',
358 triggerAction: 'all',
359 emptyText:'Select a state...',
365 Roo.MessageBox.alert("Alert", "Add Pressed");
369 Roo.MessageBox.alert("Alert", "Edit Pressed");
378 form5.render('form-ct5');