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 countryNames : 'Hong Kong, Singapore'
167 * ================ Form 3 =======================
169 var fs = new Roo.form.Form({
175 {legend:'Contact Information', style: 'width:320px;' },
176 new Roo.form.TextField({
177 fieldLabel: 'First Name',
182 new Roo.form.TextField({
183 fieldLabel: 'Last Name',
188 new Roo.form.TextField({
189 fieldLabel: 'Company',
194 new Roo.form.TextField({
201 new Roo.form.ComboBox({
204 store: new Roo.data.SimpleStore({
205 fields: ['abbr', 'state'],
206 data : Roo.exampledata.states // from states.js
208 displayField:'state',
211 triggerAction: 'all',
212 emptyText:'Select a state...',
217 new Roo.form.DateField({
218 fieldLabel: 'Date of Birth',
225 fs.addButton('Save');
226 fs.addButton('Cancel');
228 fs.render('form-ct3');
231 * ================ Form 4 =======================
233 var form = new Roo.form.Form({
238 form.column({width:342, labelWidth:75}); // open column, without auto close
240 {legend:'Contact Information'},
241 new Roo.form.TextField({
242 fieldLabel: 'Full Name',
248 new Roo.form.TextField({
249 fieldLabel: 'Job Title',
254 new Roo.form.TextField({
255 fieldLabel: 'Company',
260 new Roo.form.TextArea({
261 fieldLabel: 'Address',
264 preventScrollbars:true,
265 value: '123 example drive'
269 {legend:'Phone Numbers'},
270 new Roo.form.TextField({
273 value: '(123) 456 789'
276 new Roo.form.TextField({
277 fieldLabel: 'Business',
281 new Roo.form.TextField({
282 fieldLabel: 'Mobile',
286 new Roo.form.TextField({
291 form.end(); // closes the last container element (column, layout, fieldset, etc) and moves up 1 level in the stack
295 {width:202, style:'margin-left:10px', clear:true}
299 {id:'photo', legend:'Photo'}
304 {legend:'Options', hideLabels:true},
305 new Roo.form.Checkbox({
306 boxLabel:'RooJS v1.1.1',
310 new Roo.form.Checkbox({
311 boxLabel:'RooJS v2.0.0',
315 new Roo.form.Checkbox({
316 boxLabel:'RooScript',
323 form.end(); // close the column
326 form.applyIfToFields({
330 form.addButton('Save');
331 form.addButton('Cancel');
333 form.render('form-ct4');
335 // The form elements are standard HTML elements. By assigning an id (as we did above)
336 // we can manipulate them like any other element
337 var photo = Roo.get('photo');
338 var c = photo.createChild({
342 src: 'roojs_icon.jpg',
343 style:'margin-bottom:5px;'
350 form5 = new Roo.form.Form({
358 fieldLabel: 'A checkbox',
359 boxLabel:'RooJS v1.1.1',
366 xtype : 'DisplayField',
369 fieldLabel: 'Simple',
370 value : 'example text'
378 xtype: 'SimpleStore',
380 fields: ['abbr', 'state'],
381 data : Roo.exampledata.states // from states.js
383 displayField:'state',
386 triggerAction: 'all',
387 emptyText:'Select a state...',
393 Roo.MessageBox.alert("Alert", "Add Pressed");
397 Roo.MessageBox.alert("Alert", "Edit Pressed");
406 form5.render('form-ct5');