commit extjs-2.2.1
[extjs.git] / source / widgets / form / BasicForm.js
1 /*\r
2  * Ext JS Library 2.2.1\r
3  * Copyright(c) 2006-2009, Ext JS, LLC.\r
4  * licensing@extjs.com\r
5  * \r
6  * http://extjs.com/license\r
7  */\r
8 \r
9 /**\r
10  * @class Ext.form.BasicForm\r
11  * @extends Ext.util.Observable\r
12  * <p>Encapsulates the DOM &lt;form> element at the heart of the {@link Ext.form.FormPanel FormPanel} class, and provides\r
13  * input field management, validation, submission, and form loading services.</p>\r
14  * <p>By default, Ext Forms are submitted through Ajax, using an instance of {@link Ext.form.Action.Submit}.\r
15  * To enable normal browser submission of an Ext Form, use the {@link #standardSubmit} config option.</p>\r
16  * <p><h3>File Uploads</h3>{@link #fileUpload File uploads} are not performed using Ajax submission, that\r
17  * is they are <b>not</b> performed using XMLHttpRequests. Instead the form is submitted in the standard\r
18  * manner with the DOM <tt>&lt;form></tt> element temporarily modified to have its\r
19  * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer\r
20  * to a dynamically generated, hidden <tt>&lt;iframe></tt> which is inserted into the document\r
21  * but removed after the return data has been gathered.</p>\r
22  * <p>The server response is parsed by the browser to create the document for the IFRAME. If the\r
23  * server is using JSON to send the return object, then the\r
24  * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> header\r
25  * must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p>\r
26  * <p>Characters which are significant to an HTML parser must be sent as HTML entities, so encode\r
27  * "&lt;" as "&amp;lt;", "&amp;" as "&amp;amp;" etc.</p>\r
28  * <p>The response text is retrieved from the document, and a fake XMLHttpRequest object\r
29  * is created containing a <tt>responseText</tt> property in order to conform to the\r
30  * requirements of event handlers and callbacks.</p>\r
31  * <p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>\r
32  * and some server technologies (notably JEE) may require some custom processing in order to\r
33  * retrieve parameter names and parameter values from the packet content.</p>\r
34  * @constructor\r
35  * @param {Mixed} el The form element or its id\r
36  * @param {Object} config Configuration options\r
37  */\r
38 Ext.form.BasicForm = function(el, config){\r
39     Ext.apply(this, config);\r
40     /*\r
41      * The Ext.form.Field items in this form.\r
42      * @type MixedCollection\r
43      */\r
44     this.items = new Ext.util.MixedCollection(false, function(o){\r
45         return o.id || (o.id = Ext.id());\r
46     });\r
47     this.addEvents(\r
48         /**\r
49          * @event beforeaction\r
50          * Fires before any action is performed. Return false to cancel the action.\r
51          * @param {Form} this\r
52          * @param {Action} action The {@link Ext.form.Action} to be performed\r
53          */\r
54         'beforeaction',\r
55         /**\r
56          * @event actionfailed\r
57          * Fires when an action fails.\r
58          * @param {Form} this\r
59          * @param {Action} action The {@link Ext.form.Action} that failed\r
60          */\r
61         'actionfailed',\r
62         /**\r
63          * @event actioncomplete\r
64          * Fires when an action is completed.\r
65          * @param {Form} this\r
66          * @param {Action} action The {@link Ext.form.Action} that completed\r
67          */\r
68         'actioncomplete'\r
69     );\r
70 \r
71     if(el){\r
72         this.initEl(el);\r
73     }\r
74     Ext.form.BasicForm.superclass.constructor.call(this);\r
75 };\r
76 \r
77 Ext.extend(Ext.form.BasicForm, Ext.util.Observable, {\r
78     /**\r
79      * @cfg {String} method\r
80      * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.\r
81      */\r
82     /**\r
83      * @cfg {DataReader} reader\r
84      * An Ext.data.DataReader (e.g. {@link Ext.data.XmlReader}) to be used to read data when executing "load" actions.\r
85      * This is optional as there is built-in support for processing JSON.\r
86      */\r
87     /**\r
88      * @cfg {DataReader} errorReader\r
89      * <p>An Ext.data.DataReader (e.g. {@link Ext.data.XmlReader}) to be used to read field error messages returned from "submit" actions.\r
90      * This is completely optional as there is built-in support for processing JSON.</p>\r
91      * <p>The Records which provide messages for the invalid Fields must use the Field name (or id) as the Record ID,\r
92      * and must contain a field called "msg" which contains the error message.</p>\r
93      * <p>The errorReader does not have to be a full-blown implementation of a DataReader. It simply needs to implement a \r
94      * <tt>read(xhr)</tt> function which returns an Array of Records in an object with the following structure:<pre><code>\r
95 {\r
96     records: recordArray\r
97 }\r
98 </code></pre>\r
99      */\r
100     /**\r
101      * @cfg {String} url\r
102      * The URL to use for form actions if one isn't supplied in the action options.\r
103      */\r
104     /**\r
105      * @cfg {Boolean} fileUpload\r
106      * Set to true if this form is a file upload.\r
107      * <p>File uploads are not performed using normal "Ajax" techniques, that is they are <b>not</b>\r
108      * performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the\r
109      * DOM <tt>&lt;form></tt> element temporarily modified to have its\r
110      * <a href="http://www.w3.org/TR/REC-html40/present/frames.html#adef-target">target</a> set to refer\r
111      * to a dynamically generated, hidden <tt>&lt;iframe></tt> which is inserted into the document\r
112      * but removed after the return data has been gathered.</p>\r
113      * <p>The server response is parsed by the browser to create the document for the IFRAME. If the\r
114      * server is using JSON to send the return object, then the\r
115      * <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17">Content-Type</a> header\r
116      * must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.</p>\r
117      * <p>Characters which are significant to an HTML parser must be sent as HTML entities, so encode\r
118      * "&lt;" as "&amp;lt;", "&amp;" as "&amp;amp;" etc.</p>\r
119      * <p>The response text is retrieved from the document, and a fake XMLHttpRequest object\r
120      * is created containing a <tt>responseText</tt> property in order to conform to the\r
121      * requirements of event handlers and callbacks.</p>\r
122      * <p>Be aware that file upload packets are sent with the content type <a href="http://www.faqs.org/rfcs/rfc2388.html">multipart/form</a>\r
123      * and some server technologies (notably JEE) may require some custom processing in order to\r
124      * retrieve parameter names and parameter values from the packet content.</p>\r
125      */\r
126     /**\r
127      * @cfg {Object} baseParams\r
128      * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.\r
129      */\r
130     /**\r
131      * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).\r
132      */\r
133     timeout: 30,\r
134 \r
135     // private\r
136     activeAction : null,\r
137 \r
138     /**\r
139      * @cfg {Boolean} trackResetOnLoad If set to true, form.reset() resets to the last loaded\r
140      * or setValues() data instead of when the form was first created.\r
141      */\r
142     trackResetOnLoad : false,\r
143 \r
144     /**\r
145      * @cfg {Boolean} standardSubmit If set to true, standard HTML form submits are used instead of XHR (Ajax) style\r
146      * form submissions. (defaults to false)<br>\r
147      * <p><b>Note:</b> When using standardSubmit, any the options to {@link #submit} are\r
148      * ignored because Ext's Ajax infrastracture is bypassed. To pass extra parameters, you will need to create\r
149      * hidden fields within the form.</p>\r
150      */\r
151     /**\r
152      * By default wait messages are displayed with Ext.MessageBox.wait. You can target a specific\r
153      * element by passing it or its id or mask the form itself by passing in true.\r
154      * @type Mixed\r
155      * @property waitMsgTarget\r
156      */\r
157 \r
158     // private\r
159     initEl : function(el){\r
160         this.el = Ext.get(el);\r
161         this.id = this.el.id || Ext.id();\r
162         if(!this.standardSubmit){\r
163             this.el.on('submit', this.onSubmit, this);\r
164         }\r
165         this.el.addClass('x-form');\r
166     },\r
167 \r
168     /**\r
169      * Get the HTML form Element\r
170      * @return Ext.Element\r
171      */\r
172     getEl: function(){\r
173         return this.el;\r
174     },\r
175 \r
176     // private\r
177     onSubmit : function(e){\r
178         e.stopEvent();\r
179     },\r
180 \r
181     // private\r
182     destroy: function() {\r
183         this.items.each(function(f){\r
184             Ext.destroy(f);\r
185         });\r
186         if(this.el){\r
187             this.el.removeAllListeners();\r
188             this.el.remove();\r
189         }\r
190         this.purgeListeners();\r
191     },\r
192 \r
193     /**\r
194      * Returns true if client-side validation on the form is successful.\r
195      * @return Boolean\r
196      */\r
197     isValid : function(){\r
198         var valid = true;\r
199         this.items.each(function(f){\r
200            if(!f.validate()){\r
201                valid = false;\r
202            }\r
203         });\r
204         return valid;\r
205     },\r
206 \r
207     /**\r
208      * Returns true if any fields in this form have changed since their original load.\r
209      * @return Boolean\r
210      */\r
211     isDirty : function(){\r
212         var dirty = false;\r
213         this.items.each(function(f){\r
214            if(f.isDirty()){\r
215                dirty = true;\r
216                return false;\r
217            }\r
218         });\r
219         return dirty;\r
220     },\r
221 \r
222     /**\r
223      * Performs a predefined action ({@link Ext.form.Action.Submit} or\r
224      * {@link Ext.form.Action.Load}) or a custom extension of {@link Ext.form.Action} \r
225      * to perform application-specific processing.\r
226      * @param {String/Object} actionName The name of the predefined action type,\r
227      * or instance of {@link Ext.form.Action} to perform.\r
228      * @param {Object} options (optional) The options to pass to the {@link Ext.form.Action}. \r
229      * All of the config options listed below are supported by both the submit\r
230      * and load actions unless otherwise noted (custom actions could also accept\r
231      * other config options):<ul>\r
232      * <li><b>url</b> : String<p style="margin-left:1em">The url for the action (defaults\r
233      * to the form's url.)</p></li>\r
234      * <li><b>method</b> : String<p style="margin-left:1em">The form method to use (defaults\r
235      * to the form's method, or POST if not defined)</p></li>\r
236      * <li><b>params</b> : String/Object<p style="margin-left:1em">The params to pass\r
237      * (defaults to the form's baseParams, or none if not defined)</p></li>\r
238      * <li><b>headers</b> : Object<p style="margin-left:1em">Request headers to set for the action\r
239      * (defaults to the form's default headers)</p></li>\r
240      * <li><b>success</b> : Function<p style="margin-left:1em">The callback that will\r
241      * be invoked after a successful response.  The function is passed the following parameters:<ul>\r
242      * <li><code>form</code> : Ext.form.BasicForm<div class="sub-desc">The form that requested the action</div></li>\r
243      * <li><code>action</code> : Ext.form.Action<div class="sub-desc">The {@link Ext.form.Action Action} object which performed the operation. The {@link Ext.form.Action#result result}\r
244      * property of this object may be examined to perform custom postprocessing.</div></li>\r
245      * </ul></p></li>\r
246      * <li><b>failure</b> : Function<p style="margin-left:1em">The callback that will\r
247      * be invoked after a failed transaction attempt.  The function\r
248      * is passed the following parameters:<ul>\r
249      * <li><code>form</code> : Ext.form.BasicForm<div class="sub-desc">The form that requested the action</div></li>\r
250      * <li><code>action</code> : Ext.form.Action<div class="sub-desc">The {@link Ext.form.Action Action} object which performed the operation. If an Ajax\r
251      * error ocurred, the failure type will be in {@link Ext.form.Action#failureType failureType}. The {@link Ext.form.Action#result result}\r
252      * property of this object may be examined to perform custom postprocessing.</div></li>\r
253      * </ul></p></li>\r
254      * <li><b>scope</b> : Object<p style="margin-left:1em">The scope in which to call the\r
255      * callback functions (The <tt>this</tt> reference for the callback functions).</p></li>\r
256      * <li><b>clientValidation</b> : Boolean<p style="margin-left:1em">Submit Action only.\r
257      * Determines whether a Form's fields are validated in a final call to\r
258      * {@link Ext.form.BasicForm#isValid isValid} prior to submission. Set to <tt>false</tt>\r
259      * to prevent this. If undefined, pre-submission field validation is performed.</p></li></ul>\r
260      * @return {BasicForm} this\r
261      */\r
262     doAction : function(action, options){\r
263         if(typeof action == 'string'){\r
264             action = new Ext.form.Action.ACTION_TYPES[action](this, options);\r
265         }\r
266         if(this.fireEvent('beforeaction', this, action) !== false){\r
267             this.beforeAction(action);\r
268             action.run.defer(100, action);\r
269         }\r
270         return this;\r
271     },\r
272 \r
273     /**\r
274      * Shortcut to do a submit action.\r
275      * @param {Object} options The options to pass to the action (see {@link #doAction} for details).<br>\r
276      * <p><b>Note:</b> this is ignored when using the {@link #standardSubmit} option.</p>\r
277      * <p>The following code:</p><pre><code>\r
278 myFormPanel.getForm().submit({\r
279     clientValidation: true,\r
280     url: 'updateConsignment.php',\r
281     params: {\r
282         newStatus: 'delivered'\r
283     },\r
284     success: function(form, action) {\r
285        Ext.Msg.alert("Success", action.result.msg);\r
286     },\r
287     failure: function(form, action) {\r
288         switch (action.failureType) {\r
289             case Ext.form.Action.CLIENT_INVALID:\r
290                 Ext.Msg.alert("Failure", "Form fields may not be submitted with invalid values");\r
291                 break;\r
292             case Ext.form.Action.CONNECT_FAILURE:\r
293                 Ext.Msg.alert("Failure", "Ajax communication failed");\r
294                 break;\r
295             case Ext.form.Action.SERVER_INVALID:\r
296                Ext.Msg.alert("Failure", action.result.msg);\r
297        }\r
298     }\r
299 });\r
300 </code></pre>\r
301      * would process the following server response for a successful submission:<pre><code>\r
302 {\r
303     success: true,\r
304     msg: 'Consignment updated'\r
305 }\r
306 </code></pre>\r
307      * and the following server response for a failed submission:<pre><code>\r
308 {\r
309     success: false,\r
310     msg: 'You do not have permission to perform this operation'\r
311 }\r
312 </code></pre>\r
313      * @return {BasicForm} this\r
314      */\r
315     submit : function(options){\r
316         if(this.standardSubmit){\r
317             var v = this.isValid();\r
318             if(v){\r
319                 this.el.dom.submit();\r
320             }\r
321             return v;\r
322         }\r
323         this.doAction('submit', options);\r
324         return this;\r
325     },\r
326 \r
327     /**\r
328      * Shortcut to do a load action.\r
329      * @param {Object} options The options to pass to the action (see {@link #doAction} for details)\r
330      * @return {BasicForm} this\r
331      */\r
332     load : function(options){\r
333         this.doAction('load', options);\r
334         return this;\r
335     },\r
336 \r
337     /**\r
338      * Persists the values in this form into the passed Ext.data.Record object in a beginEdit/endEdit block.\r
339      * @param {Record} record The record to edit\r
340      * @return {BasicForm} this\r
341      */\r
342     updateRecord : function(record){\r
343         record.beginEdit();\r
344         var fs = record.fields;\r
345         fs.each(function(f){\r
346             var field = this.findField(f.name);\r
347             if(field){\r
348                 record.set(f.name, field.getValue());\r
349             }\r
350         }, this);\r
351         record.endEdit();\r
352         return this;\r
353     },\r
354 \r
355     /**\r
356      * Loads an Ext.data.Record into this form.\r
357      * @param {Record} record The record to load\r
358      * @return {BasicForm} this\r
359      */\r
360     loadRecord : function(record){\r
361         this.setValues(record.data);\r
362         return this;\r
363     },\r
364 \r
365     // private\r
366     beforeAction : function(action){\r
367         var o = action.options;\r
368         if(o.waitMsg){\r
369             if(this.waitMsgTarget === true){\r
370                 this.el.mask(o.waitMsg, 'x-mask-loading');\r
371             }else if(this.waitMsgTarget){\r
372                 this.waitMsgTarget = Ext.get(this.waitMsgTarget);\r
373                 this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');\r
374             }else{\r
375                 Ext.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle || 'Please Wait...');\r
376             }\r
377         }\r
378     },\r
379 \r
380     // private\r
381     afterAction : function(action, success){\r
382         this.activeAction = null;\r
383         var o = action.options;\r
384         if(o.waitMsg){\r
385             if(this.waitMsgTarget === true){\r
386                 this.el.unmask();\r
387             }else if(this.waitMsgTarget){\r
388                 this.waitMsgTarget.unmask();\r
389             }else{\r
390                 Ext.MessageBox.updateProgress(1);\r
391                 Ext.MessageBox.hide();\r
392             }\r
393         }\r
394         if(success){\r
395             if(o.reset){\r
396                 this.reset();\r
397             }\r
398             Ext.callback(o.success, o.scope, [this, action]);\r
399             this.fireEvent('actioncomplete', this, action);\r
400         }else{\r
401             Ext.callback(o.failure, o.scope, [this, action]);\r
402             this.fireEvent('actionfailed', this, action);\r
403         }\r
404     },\r
405 \r
406     /**\r
407      * Find a Ext.form.Field in this form by id, dataIndex, name or hiddenName.\r
408      * @param {String} id The value to search for\r
409      * @return Field\r
410      */\r
411     findField : function(id){\r
412         var field = this.items.get(id);\r
413         if(!field){\r
414             this.items.each(function(f){\r
415                 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){\r
416                     field = f;\r
417                     return false;\r
418                 }\r
419             });\r
420         }\r
421         return field || null;\r
422     },\r
423 \r
424 \r
425     /**\r
426      * Mark fields in this form invalid in bulk.\r
427      * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}\r
428      * @return {BasicForm} this\r
429      */\r
430     markInvalid : function(errors){\r
431         if(Ext.isArray(errors)){\r
432             for(var i = 0, len = errors.length; i < len; i++){\r
433                 var fieldError = errors[i];\r
434                 var f = this.findField(fieldError.id);\r
435                 if(f){\r
436                     f.markInvalid(fieldError.msg);\r
437                 }\r
438             }\r
439         }else{\r
440             var field, id;\r
441             for(id in errors){\r
442                 if(typeof errors[id] != 'function' && (field = this.findField(id))){\r
443                     field.markInvalid(errors[id]);\r
444                 }\r
445             }\r
446         }\r
447         return this;\r
448     },\r
449 \r
450     /**\r
451      * Set values for fields in this form in bulk.\r
452      * @param {Array/Object} values Either an array in the form:<br><br><code><pre>\r
453 [{id:'clientName', value:'Fred. Olsen Lines'},\r
454  {id:'portOfLoading', value:'FXT'},\r
455  {id:'portOfDischarge', value:'OSL'} ]</pre></code><br><br>\r
456      * or an object hash of the form:<br><br><code><pre>\r
457 {\r
458     clientName: 'Fred. Olsen Lines',\r
459     portOfLoading: 'FXT',\r
460     portOfDischarge: 'OSL'\r
461 }</pre></code><br>\r
462      * @return {BasicForm} this\r
463      */\r
464     setValues : function(values){\r
465         if(Ext.isArray(values)){ // array of objects\r
466             for(var i = 0, len = values.length; i < len; i++){\r
467                 var v = values[i];\r
468                 var f = this.findField(v.id);\r
469                 if(f){\r
470                     f.setValue(v.value);\r
471                     if(this.trackResetOnLoad){\r
472                         f.originalValue = f.getValue();\r
473                     }\r
474                 }\r
475             }\r
476         }else{ // object hash\r
477             var field, id;\r
478             for(id in values){\r
479                 if(typeof values[id] != 'function' && (field = this.findField(id))){\r
480                     field.setValue(values[id]);\r
481                     if(this.trackResetOnLoad){\r
482                         field.originalValue = field.getValue();\r
483                     }\r
484                 }\r
485             }\r
486         }\r
487         return this;\r
488     },\r
489 \r
490     /**\r
491      * <p>Returns the fields in this form as an object with key/value pairs as they would be submitted using a standard form submit.\r
492      * If multiple fields exist with the same name they are returned as an array.</p>\r
493      *\r
494      * <p><b>Note:</b> The values are collected from all enabled HTML input elements within the form, <u>not</u> from\r
495      * the Ext Field objects. This means that all returned values are Strings (or Arrays of Strings) and that the the\r
496      * value can potentionally be the emptyText of a field.</p>\r
497      * @param {Boolean} asString (optional) false to return the values as an object (defaults to returning as a string)\r
498      * @return {String/Object}\r
499      */\r
500     getValues : function(asString){\r
501         var fs = Ext.lib.Ajax.serializeForm(this.el.dom);\r
502         if(asString === true){\r
503             return fs;\r
504         }\r
505         return Ext.urlDecode(fs);\r
506     },\r
507 \r
508     /**\r
509      * Clears all invalid messages in this form.\r
510      * @return {BasicForm} this\r
511      */\r
512     clearInvalid : function(){\r
513         this.items.each(function(f){\r
514            f.clearInvalid();\r
515         });\r
516         return this;\r
517     },\r
518 \r
519     /**\r
520      * Resets this form.\r
521      * @return {BasicForm} this\r
522      */\r
523     reset : function(){\r
524         this.items.each(function(f){\r
525             f.reset();\r
526         });\r
527         return this;\r
528     },\r
529 \r
530     /**\r
531      * Add Ext.form Components to this form's Collection. This does not result in rendering of\r
532      * the passed Component, it just enables the form to validate Fields, and distribute values to\r
533      * Fields.\r
534      * <p><b>You will not usually call this function. In order to be rendered, a Field must be added\r
535      * to a {@link Ext.Container Container}, usually an {@link Ext.form.FormPanel FormPanel}.\r
536      * The FormPanel to which the field is added takes care of adding the Field to the BasicForm's\r
537      * collection.</b></p>\r
538      * @param {Field} field1\r
539      * @param {Field} field2 (optional)\r
540      * @param {Field} etc (optional)\r
541      * @return {BasicForm} this\r
542      */\r
543     add : function(){\r
544         this.items.addAll(Array.prototype.slice.call(arguments, 0));\r
545         return this;\r
546     },\r
547 \r
548 \r
549     /**\r
550      * Removes a field from the items collection (does NOT remove its markup).\r
551      * @param {Field} field\r
552      * @return {BasicForm} this\r
553      */\r
554     remove : function(field){\r
555         this.items.remove(field);\r
556         return this;\r
557     },\r
558 \r
559     /**\r
560      * Iterates through the {@link Ext.form.Field Field}s which have been {@link #add add}ed to this BasicForm,\r
561      * checks them for an id attribute, and calls {@link Ext.form.Field#applyToMarkup} on the existing dom element with that id.\r
562      * @return {BasicForm} this\r
563      */\r
564     render : function(){\r
565         this.items.each(function(f){\r
566             if(f.isFormField && !f.rendered && document.getElementById(f.id)){ // if the element exists\r
567                 f.applyToMarkup(f.id);\r
568             }\r
569         });\r
570         return this;\r
571     },\r
572 \r
573     /**\r
574      * Calls {@link Ext#apply} for all fields in this form with the passed object.\r
575      * @param {Object} values\r
576      * @return {BasicForm} this\r
577      */\r
578     applyToFields : function(o){\r
579         this.items.each(function(f){\r
580            Ext.apply(f, o);\r
581         });\r
582         return this;\r
583     },\r
584 \r
585     /**\r
586      * Calls {@link Ext#applyIf} for all field in this form with the passed object.\r
587      * @param {Object} values\r
588      * @return {BasicForm} this\r
589      */\r
590     applyIfToFields : function(o){\r
591         this.items.each(function(f){\r
592            Ext.applyIf(f, o);\r
593         });\r
594         return this;\r
595     }\r
596 });\r
597 \r
598 // back compat\r
599 Ext.BasicForm = Ext.form.BasicForm;