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',
126 resizable: 's' /// where the handles should got..
133 mform.addButton('Save');
134 mform.addButton('Cancel');
137 mform.render('form-ct2');
140 * ================ Form 3 =======================
142 var fs = new Roo.form.Form({
148 {legend:'Contact Information', style: 'width:320px;' },
149 new Roo.form.TextField({
150 fieldLabel: 'First Name',
155 new Roo.form.TextField({
156 fieldLabel: 'Last Name',
161 new Roo.form.TextField({
162 fieldLabel: 'Company',
167 new Roo.form.TextField({
174 new Roo.form.ComboBox({
177 store: new Roo.data.SimpleStore({
178 fields: ['abbr', 'state'],
179 data : Roo.exampledata.states // from states.js
181 displayField:'state',
184 triggerAction: 'all',
185 emptyText:'Select a state...',
190 new Roo.form.DateField({
191 fieldLabel: 'Date of Birth',
198 fs.addButton('Save');
199 fs.addButton('Cancel');
201 fs.render('form-ct3');
204 * ================ Form 4 =======================
206 var form = new Roo.form.Form({
211 form.column({width:342, labelWidth:75}); // open column, without auto close
213 {legend:'Contact Information'},
214 new Roo.form.TextField({
215 fieldLabel: 'Full Name',
221 new Roo.form.TextField({
222 fieldLabel: 'Job Title',
227 new Roo.form.TextField({
228 fieldLabel: 'Company',
233 new Roo.form.TextArea({
234 fieldLabel: 'Address',
237 preventScrollbars:true,
238 value: '123 example drive'
242 {legend:'Phone Numbers'},
243 new Roo.form.TextField({
246 value: '(123) 456 789'
249 new Roo.form.TextField({
250 fieldLabel: 'Business',
254 new Roo.form.TextField({
255 fieldLabel: 'Mobile',
259 new Roo.form.TextField({
264 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
268 {width:202, style:'margin-left:10px', clear:true}
272 {id:'photo', legend:'Photo'}
277 {legend:'Options', hideLabels:true},
278 new Roo.form.Checkbox({
279 boxLabel:'RooJS v1.1.1',
283 new Roo.form.Checkbox({
284 boxLabel:'RooJS v2.0.0',
288 new Roo.form.Checkbox({
289 boxLabel:'RooScript',
296 form.end(); // close the column
299 form.applyIfToFields({
303 form.addButton('Save');
304 form.addButton('Cancel');
306 form.render('form-ct4');
308 // The form elements are standard HTML elements. By assigning an id (as we did above)
309 // we can manipulate them like any other element
310 var photo = Roo.get('photo');
311 var c = photo.createChild({
315 src: 'roojs_icon.jpg',
316 style:'margin-bottom:5px;'
323 form5 = new Roo.form.Form({
331 fieldLabel: 'A checkbox',
332 boxLabel:'RooJS v1.1.1',
339 xtype : 'DisplayField',
342 fieldLabel: 'Simple',
343 value : 'example text'
351 xtype: 'SimpleStore',
353 fields: ['abbr', 'state'],
354 data : Roo.exampledata.states // from states.js
356 displayField:'state',
359 triggerAction: 'all',
360 emptyText:'Select a state...',
366 Roo.MessageBox.alert("Alert", "Add Pressed");
370 Roo.MessageBox.alert("Alert", "Edit Pressed");
379 form5.render('form-ct5');