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({
76 width: 272, // precise column sizes or percentages or straight CSS
80 fieldLabel: 'First Name',
86 fieldLabel: 'Company',
96 style:'margin-left:10px',
101 fieldLabel: 'Last Name',
121 xtype : 'HtmlEditor',
123 fieldLabel:'Biography',
132 mform.addButton('Save');
133 mform.addButton('Cancel');
136 mform.render('form-ct2');
139 * ================ Form 3 =======================
141 var fs = new Roo.form.Form({
147 {legend:'Contact Information', style: 'width:320px;' },
148 new Roo.form.TextField({
149 fieldLabel: 'First Name',
154 new Roo.form.TextField({
155 fieldLabel: 'Last Name',
160 new Roo.form.TextField({
161 fieldLabel: 'Company',
166 new Roo.form.TextField({
173 new Roo.form.ComboBox({
176 store: new Roo.data.SimpleStore({
177 fields: ['abbr', 'state'],
178 data : Roo.exampledata.states // from states.js
180 displayField:'state',
183 triggerAction: 'all',
184 emptyText:'Select a state...',
189 new Roo.form.DateField({
190 fieldLabel: 'Date of Birth',
197 fs.addButton('Save');
198 fs.addButton('Cancel');
200 fs.render('form-ct3');
203 * ================ Form 4 =======================
205 var form = new Roo.form.Form({
210 form.column({width:342, labelWidth:75}); // open column, without auto close
212 {legend:'Contact Information'},
213 new Roo.form.TextField({
214 fieldLabel: 'Full Name',
220 new Roo.form.TextField({
221 fieldLabel: 'Job Title',
226 new Roo.form.TextField({
227 fieldLabel: 'Company',
232 new Roo.form.TextArea({
233 fieldLabel: 'Address',
236 preventScrollbars:true,
237 value: '123 example drive'
241 {legend:'Phone Numbers'},
242 new Roo.form.TextField({
245 value: '(123) 456 789'
248 new Roo.form.TextField({
249 fieldLabel: 'Business',
253 new Roo.form.TextField({
254 fieldLabel: 'Mobile',
258 new Roo.form.TextField({
263 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
267 {width:202, style:'margin-left:10px', clear:true}
271 {id:'photo', legend:'Photo'}
276 {legend:'Options', hideLabels:true},
277 new Roo.form.Checkbox({
278 boxLabel:'RooJS v1.1.1',
282 new Roo.form.Checkbox({
283 boxLabel:'RooJS v2.0.0',
287 new Roo.form.Checkbox({
288 boxLabel:'RooScript',
295 form.end(); // close the column
298 form.applyIfToFields({
302 form.addButton('Save');
303 form.addButton('Cancel');
305 form.render('form-ct4');
307 // The form elements are standard HTML elements. By assigning an id (as we did above)
308 // we can manipulate them like any other element
309 var photo = Roo.get('photo');
310 var c = photo.createChild({
314 src: 'roojs_icon.jpg',
315 style:'margin-bottom:5px;'
322 form5 = new Roo.form.Form({
330 fieldLabel: 'A checkbox',
331 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');