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({
77 width: 500, // precise column sizes or percentages or straight CSS
80 xtype : 'ComboBoxArray',
82 fieldLabel: 'Multi select test',
84 hiddenName: 'countryNames',
98 width: 272, // precise column sizes or percentages or straight CSS
102 fieldLabel: 'First Name',
108 fieldLabel: 'Company',
118 style:'margin-left:10px',
123 fieldLabel: 'Last Name',
143 xtype : 'HtmlEditor',
145 fieldLabel:'Biography',
148 resizable: 's' /// where the handles should got..
155 mform.addButton('Save');
156 mform.addButton('Cancel');
159 mform.render('form-ct2');
162 * ================ Form 3 =======================
164 var fs = new Roo.form.Form({
170 {legend:'Contact Information', style: 'width:320px;' },
171 new Roo.form.TextField({
172 fieldLabel: 'First Name',
177 new Roo.form.TextField({
178 fieldLabel: 'Last Name',
183 new Roo.form.TextField({
184 fieldLabel: 'Company',
189 new Roo.form.TextField({
196 new Roo.form.ComboBox({
199 store: new Roo.data.SimpleStore({
200 fields: ['abbr', 'state'],
201 data : Roo.exampledata.states // from states.js
203 displayField:'state',
206 triggerAction: 'all',
207 emptyText:'Select a state...',
212 new Roo.form.DateField({
213 fieldLabel: 'Date of Birth',
220 fs.addButton('Save');
221 fs.addButton('Cancel');
223 fs.render('form-ct3');
226 * ================ Form 4 =======================
228 var form = new Roo.form.Form({
233 form.column({width:342, labelWidth:75}); // open column, without auto close
235 {legend:'Contact Information'},
236 new Roo.form.TextField({
237 fieldLabel: 'Full Name',
243 new Roo.form.TextField({
244 fieldLabel: 'Job Title',
249 new Roo.form.TextField({
250 fieldLabel: 'Company',
255 new Roo.form.TextArea({
256 fieldLabel: 'Address',
259 preventScrollbars:true,
260 value: '123 example drive'
264 {legend:'Phone Numbers'},
265 new Roo.form.TextField({
268 value: '(123) 456 789'
271 new Roo.form.TextField({
272 fieldLabel: 'Business',
276 new Roo.form.TextField({
277 fieldLabel: 'Mobile',
281 new Roo.form.TextField({
286 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
290 {width:202, style:'margin-left:10px', clear:true}
294 {id:'photo', legend:'Photo'}
299 {legend:'Options', hideLabels:true},
300 new Roo.form.Checkbox({
301 boxLabel:'RooJS v1.1.1',
305 new Roo.form.Checkbox({
306 boxLabel:'RooJS v2.0.0',
310 new Roo.form.Checkbox({
311 boxLabel:'RooScript',
318 form.end(); // close the column
321 form.applyIfToFields({
325 form.addButton('Save');
326 form.addButton('Cancel');
328 form.render('form-ct4');
330 // The form elements are standard HTML elements. By assigning an id (as we did above)
331 // we can manipulate them like any other element
332 var photo = Roo.get('photo');
333 var c = photo.createChild({
337 src: 'roojs_icon.jpg',
338 style:'margin-bottom:5px;'
345 form5 = new Roo.form.Form({
353 fieldLabel: 'A checkbox',
354 boxLabel:'RooJS v1.1.1',
361 xtype : 'DisplayField',
364 fieldLabel: 'Simple',
365 value : 'example text'
373 xtype: 'SimpleStore',
375 fields: ['abbr', 'state'],
376 data : Roo.exampledata.states // from states.js
378 displayField:'state',
381 triggerAction: 'all',
382 emptyText:'Select a state...',
388 Roo.MessageBox.alert("Alert", "Add Pressed");
392 Roo.MessageBox.alert("Alert", "Edit Pressed");
401 form5.render('form-ct5');