sync
[roojs1] / docs / symbols / src / Roo_form_BasicForm.js.html
1 <html><head><title>../roojs1/Roo/form/BasicForm.js</title><link rel="stylesheet" type="text/css" href="../../../css/highlight-js.css"/></head><body class="highlightpage"><code class="jsdoc-pretty"><span class="jsdoc-comment">/*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * &lt;script type=&quot;text/javascript&quot;&gt;
10  */
11  
12 /**
13  * @class Roo.form.BasicForm
14  * @extends Roo.util.Observable
15  * Supplies the functionality to do &quot;actions&quot; on forms and initialize Roo.form.Field types on existing markup.
16  * @constructor
17  * @param {String/HTMLElement/Roo.Element} el The form element or its id
18  * @param {Object} config Configuration options
19  */
20 </span><span class="jsdoc-var">Roo.form.BasicForm </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">el</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">config</span><span class="jsdoc-syntax">){
21     </span><span class="jsdoc-var">this.allItems </span><span class="jsdoc-syntax">= [];
22     </span><span class="jsdoc-var">this.childForms </span><span class="jsdoc-syntax">= [];
23     </span><span class="jsdoc-var">Roo.apply</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">config</span><span class="jsdoc-syntax">);
24     </span><span class="jsdoc-comment">/*
25      * The Roo.form.Field items in this form.
26      * @type MixedCollection
27      */
28      
29      
30     </span><span class="jsdoc-var">this.items </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.util.MixedCollection</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">, </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">){
31         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">o.id </span><span class="jsdoc-syntax">|| (</span><span class="jsdoc-var">o.id </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">Roo.id</span><span class="jsdoc-syntax">());
32     });
33     </span><span class="jsdoc-var">this.addEvents</span><span class="jsdoc-syntax">({
34         </span><span class="jsdoc-comment">/**
35          * @event beforeaction
36          * Fires before any action is performed. Return false to cancel the action.
37          * @param {Form} this
38          * @param {Action} action The action to be performed
39          */
40         </span><span class="jsdoc-var">beforeaction</span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">,
41         </span><span class="jsdoc-comment">/**
42          * @event actionfailed
43          * Fires when an action fails.
44          * @param {Form} this
45          * @param {Action} action The action that failed
46          */
47         </span><span class="jsdoc-var">actionfailed </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">,
48         </span><span class="jsdoc-comment">/**
49          * @event actioncomplete
50          * Fires when an action is completed.
51          * @param {Form} this
52          * @param {Action} action The action that completed
53          */
54         </span><span class="jsdoc-var">actioncomplete </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">true
55     </span><span class="jsdoc-syntax">});
56     </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">el</span><span class="jsdoc-syntax">){
57         </span><span class="jsdoc-var">this.initEl</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">el</span><span class="jsdoc-syntax">);
58     }
59     </span><span class="jsdoc-var">Roo.form.BasicForm.superclass.constructor.call</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">);
60 };
61
62 </span><span class="jsdoc-var">Roo.extend</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Roo.form.BasicForm</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">Roo.util.Observable</span><span class="jsdoc-syntax">, {
63     </span><span class="jsdoc-comment">/**
64      * @cfg {String} method
65      * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
66      */
67     /**
68      * @cfg {DataReader} reader
69      * An Roo.data.DataReader (e.g. {@link Roo.data.XmlReader}) to be used to read data when executing &quot;load&quot; actions.
70      * This is optional as there is built-in support for processing JSON.
71      */
72     /**
73      * @cfg {DataReader} errorReader
74      * An Roo.data.DataReader (e.g. {@link Roo.data.XmlReader}) to be used to read data when reading validation errors on &quot;submit&quot; actions.
75      * This is completely optional as there is built-in support for processing JSON.
76      */
77     /**
78      * @cfg {String} url
79      * The URL to use for form actions if one isn't supplied in the action options.
80      */
81     /**
82      * @cfg {Boolean} fileUpload
83      * Set to true if this form is a file upload.
84      */
85     /**
86      * @cfg {Object} baseParams
87      * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
88      */
89     /**
90      * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
91      */
92     </span><span class="jsdoc-var">timeout</span><span class="jsdoc-syntax">: 30,
93
94     </span><span class="jsdoc-comment">// private
95     </span><span class="jsdoc-var">activeAction </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">null</span><span class="jsdoc-syntax">,
96
97     </span><span class="jsdoc-comment">/**
98      * @cfg {Boolean} trackResetOnLoad If set to true, form.reset() resets to the last loaded
99      * or setValues() data instead of when the form was first created.
100      */
101     </span><span class="jsdoc-var">trackResetOnLoad </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
102     
103     
104     </span><span class="jsdoc-comment">/**
105      * childForms - used for multi-tab forms
106      * @type {Array}
107      */
108     </span><span class="jsdoc-var">childForms </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
109     
110     </span><span class="jsdoc-comment">/**
111      * allItems - full list of fields.
112      * @type {Array}
113      */
114     </span><span class="jsdoc-var">allItems </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
115     
116     </span><span class="jsdoc-comment">/**
117      * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
118      * element by passing it or its id or mask the form itself by passing in true.
119      * @type Mixed
120      */
121     </span><span class="jsdoc-var">waitMsgTarget </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">undefined</span><span class="jsdoc-syntax">,
122
123     </span><span class="jsdoc-comment">// private
124     </span><span class="jsdoc-var">initEl </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">el</span><span class="jsdoc-syntax">){
125         </span><span class="jsdoc-var">this.el </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">Roo.get</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">el</span><span class="jsdoc-syntax">);
126         </span><span class="jsdoc-var">this.id </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.el.id </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">Roo.id</span><span class="jsdoc-syntax">();
127         </span><span class="jsdoc-var">this.el.on</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'submit'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this.onSubmit</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">);
128         </span><span class="jsdoc-var">this.el.addClass</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'x-form'</span><span class="jsdoc-syntax">);
129     },
130
131     </span><span class="jsdoc-comment">// private
132     </span><span class="jsdoc-var">onSubmit </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">e</span><span class="jsdoc-syntax">){
133         </span><span class="jsdoc-var">e.stopEvent</span><span class="jsdoc-syntax">();
134     },
135
136     </span><span class="jsdoc-comment">/**
137      * Returns true if client-side validation on the form is successful.
138      * @return Boolean
139      */
140     </span><span class="jsdoc-var">isValid </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(){
141         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">valid </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">;
142         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
143            </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">f.validate</span><span class="jsdoc-syntax">()){
144                </span><span class="jsdoc-var">valid </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">;
145            }
146         });
147         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">valid</span><span class="jsdoc-syntax">;
148     },
149
150     </span><span class="jsdoc-comment">/**
151      * Returns true if any fields in this form have changed since their original load.
152      * @return Boolean
153      */
154     </span><span class="jsdoc-var">isDirty </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(){
155         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">dirty </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">;
156         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
157            </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.isDirty</span><span class="jsdoc-syntax">()){
158                </span><span class="jsdoc-var">dirty </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">;
159                </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
160            }
161         });
162         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">dirty</span><span class="jsdoc-syntax">;
163     },
164
165     </span><span class="jsdoc-comment">/**
166      * Performs a predefined action (submit or load) or custom actions you define on this form.
167      * @param {String} actionName The name of the action type
168      * @param {Object} options (optional) The options to pass to the action.  All of the config options listed
169      * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
170      * accept other config options):
171      * &lt;pre&gt;
172 Property          Type             Description
173 ----------------  ---------------  ----------------------------------------------------------------------------------
174 url               String           The url for the action (defaults to the form's url)
175 method            String           The form method to use (defaults to the form's method, or POST if not defined)
176 params            String/Object    The params to pass (defaults to the form's baseParams, or none if not defined)
177 clientValidation  Boolean          Applies to submit only.  Pass true to call form.isValid() prior to posting to
178                                    validate the form on the client (defaults to false)
179      * &lt;/pre&gt;
180      * @return {BasicForm} this
181      */
182     </span><span class="jsdoc-var">doAction </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">options</span><span class="jsdoc-syntax">){
183         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">typeof </span><span class="jsdoc-var">action </span><span class="jsdoc-syntax">== </span><span class="jsdoc-string">'string'</span><span class="jsdoc-syntax">){
184             </span><span class="jsdoc-var">action </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.form.Action.ACTION_TYPES</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">](</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">options</span><span class="jsdoc-syntax">);
185         }
186         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.fireEvent</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'beforeaction'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">) !== </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">){
187             </span><span class="jsdoc-var">this.beforeAction</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">);
188             </span><span class="jsdoc-var">action.run.defer</span><span class="jsdoc-syntax">(100, </span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">);
189         }
190         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
191     },
192
193     </span><span class="jsdoc-comment">/**
194      * Shortcut to do a submit action.
195      * @param {Object} options The options to pass to the action (see {@link #doAction} for details)
196      * @return {BasicForm} this
197      */
198     </span><span class="jsdoc-var">submit </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">options</span><span class="jsdoc-syntax">){
199         </span><span class="jsdoc-var">this.doAction</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'submit'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">options</span><span class="jsdoc-syntax">);
200         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
201     },
202
203     </span><span class="jsdoc-comment">/**
204      * Shortcut to do a load action.
205      * @param {Object} options The options to pass to the action (see {@link #doAction} for details)
206      * @return {BasicForm} this
207      */
208     </span><span class="jsdoc-var">load </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">options</span><span class="jsdoc-syntax">){
209         </span><span class="jsdoc-var">this.doAction</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'load'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">options</span><span class="jsdoc-syntax">);
210         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
211     },
212
213     </span><span class="jsdoc-comment">/**
214      * Persists the values in this form into the passed Roo.data.Record object in a beginEdit/endEdit block.
215      * @param {Record} record The record to edit
216      * @return {BasicForm} this
217      */
218     </span><span class="jsdoc-var">updateRecord </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">record</span><span class="jsdoc-syntax">){
219         </span><span class="jsdoc-var">record.beginEdit</span><span class="jsdoc-syntax">();
220         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">fs </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">record.fields</span><span class="jsdoc-syntax">;
221         </span><span class="jsdoc-var">fs.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
222             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">field </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.findField</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.name</span><span class="jsdoc-syntax">);
223             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">field</span><span class="jsdoc-syntax">){
224                 </span><span class="jsdoc-var">record.set</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.name</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">field.getValue</span><span class="jsdoc-syntax">());
225             }
226         }, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">);
227         </span><span class="jsdoc-var">record.endEdit</span><span class="jsdoc-syntax">();
228         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
229     },
230
231     </span><span class="jsdoc-comment">/**
232      * Loads an Roo.data.Record into this form.
233      * @param {Record} record The record to load
234      * @return {BasicForm} this
235      */
236     </span><span class="jsdoc-var">loadRecord </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">record</span><span class="jsdoc-syntax">){
237         </span><span class="jsdoc-var">this.setValues</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">record.data</span><span class="jsdoc-syntax">);
238         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
239     },
240
241     </span><span class="jsdoc-comment">// private
242     </span><span class="jsdoc-var">beforeAction </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">){
243         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">o </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">action.options</span><span class="jsdoc-syntax">;
244         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.waitMsg</span><span class="jsdoc-syntax">){
245             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.waitMsgTarget </span><span class="jsdoc-syntax">=== </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">){
246                 </span><span class="jsdoc-var">this.el.mask</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.waitMsg</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'x-mask-loading'</span><span class="jsdoc-syntax">);
247             }</span><span class="jsdoc-keyword">else if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.waitMsgTarget</span><span class="jsdoc-syntax">){
248                 </span><span class="jsdoc-var">this.waitMsgTarget </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">Roo.get</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.waitMsgTarget</span><span class="jsdoc-syntax">);
249                 </span><span class="jsdoc-var">this.waitMsgTarget.mask</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.waitMsg</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'x-mask-loading'</span><span class="jsdoc-syntax">);
250             }</span><span class="jsdoc-keyword">else</span><span class="jsdoc-syntax">{
251                 </span><span class="jsdoc-var">Roo.MessageBox.wait</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.waitMsg</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">o.waitTitle </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">this.waitTitle </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-string">'Please Wait...'</span><span class="jsdoc-syntax">);
252             }
253         }
254     },
255
256     </span><span class="jsdoc-comment">// private
257     </span><span class="jsdoc-var">afterAction </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">success</span><span class="jsdoc-syntax">){
258         </span><span class="jsdoc-var">this.activeAction </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">null</span><span class="jsdoc-syntax">;
259         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">o </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">action.options</span><span class="jsdoc-syntax">;
260         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.waitMsg</span><span class="jsdoc-syntax">){
261             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.waitMsgTarget </span><span class="jsdoc-syntax">=== </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">){
262                 </span><span class="jsdoc-var">this.el.unmask</span><span class="jsdoc-syntax">();
263             }</span><span class="jsdoc-keyword">else if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.waitMsgTarget</span><span class="jsdoc-syntax">){
264                 </span><span class="jsdoc-var">this.waitMsgTarget.unmask</span><span class="jsdoc-syntax">();
265             }</span><span class="jsdoc-keyword">else</span><span class="jsdoc-syntax">{
266                 </span><span class="jsdoc-var">Roo.MessageBox.updateProgress</span><span class="jsdoc-syntax">(1);
267                 </span><span class="jsdoc-var">Roo.MessageBox.hide</span><span class="jsdoc-syntax">();
268             }
269         }
270         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">success</span><span class="jsdoc-syntax">){
271             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.reset</span><span class="jsdoc-syntax">){
272                 </span><span class="jsdoc-var">this.reset</span><span class="jsdoc-syntax">();
273             }
274             </span><span class="jsdoc-var">Roo.callback</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.success</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">o.scope</span><span class="jsdoc-syntax">, [</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">]);
275             </span><span class="jsdoc-var">this.fireEvent</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'actioncomplete'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">);
276         }</span><span class="jsdoc-keyword">else</span><span class="jsdoc-syntax">{
277             </span><span class="jsdoc-var">Roo.callback</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o.failure</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">o.scope</span><span class="jsdoc-syntax">, [</span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">]);
278             </span><span class="jsdoc-var">this.fireEvent</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'actionfailed'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">action</span><span class="jsdoc-syntax">);
279         }
280     },
281
282     </span><span class="jsdoc-comment">/**
283      * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
284      * @param {String} id The value to search for
285      * @return Field
286      */
287     </span><span class="jsdoc-var">findField </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">){
288         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">field </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.items.get</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">);
289         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">field</span><span class="jsdoc-syntax">){
290             </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
291                 </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.isFormField </span><span class="jsdoc-syntax">&amp;&amp; (</span><span class="jsdoc-var">f.dataIndex </span><span class="jsdoc-syntax">== </span><span class="jsdoc-var">id </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">f.id </span><span class="jsdoc-syntax">== </span><span class="jsdoc-var">id </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">f.getName</span><span class="jsdoc-syntax">() == </span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">)){
292                     </span><span class="jsdoc-var">field </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">;
293                     </span><span class="jsdoc-keyword">return false</span><span class="jsdoc-syntax">;
294                 }
295             });
296         }
297         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">field </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-keyword">null</span><span class="jsdoc-syntax">;
298     },
299
300     </span><span class="jsdoc-comment">/**
301      * Add a secondary form to this one, 
302      * Used to provide tabbed forms. One form is primary, with hidden values 
303      * which mirror the elements from the other forms.
304      * 
305      * @param {Roo.form.Form} form to add.
306      * 
307      */
308     </span><span class="jsdoc-var">addForm </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">form</span><span class="jsdoc-syntax">)
309     {
310        
311         </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms.indexOf</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">form</span><span class="jsdoc-syntax">) &gt; -1) {
312             </span><span class="jsdoc-comment">// already added..
313             </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
314         }
315         </span><span class="jsdoc-var">this.childForms.push</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">form</span><span class="jsdoc-syntax">);
316         </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">form.allItems</span><span class="jsdoc-syntax">, </span><span class="jsdoc-keyword">function </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">fe</span><span class="jsdoc-syntax">) {
317             
318             </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.findField</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">fe.name</span><span class="jsdoc-syntax">)) { </span><span class="jsdoc-comment">// already added..
319                 </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
320             }
321             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">add </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.form.Hidden</span><span class="jsdoc-syntax">({
322                 </span><span class="jsdoc-var">name </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">fe.name
323             </span><span class="jsdoc-syntax">});
324             </span><span class="jsdoc-var">add.render</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.el</span><span class="jsdoc-syntax">);
325             
326             </span><span class="jsdoc-var">this.add</span><span class="jsdoc-syntax">( </span><span class="jsdoc-var">add </span><span class="jsdoc-syntax">);
327         }, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">);
328         
329     },
330     </span><span class="jsdoc-comment">/**
331      * Mark fields in this form invalid in bulk.
332      * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
333      * @return {BasicForm} this
334      */
335     </span><span class="jsdoc-var">markInvalid </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">errors</span><span class="jsdoc-syntax">){
336         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">errors </span><span class="jsdoc-keyword">instanceof </span><span class="jsdoc-var">Array</span><span class="jsdoc-syntax">){
337             </span><span class="jsdoc-keyword">for</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= 0, </span><span class="jsdoc-var">len </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">errors.length</span><span class="jsdoc-syntax">; </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">&lt; </span><span class="jsdoc-var">len</span><span class="jsdoc-syntax">; </span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">++){
338                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">fieldError </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">errors</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">];
339                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">f </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.findField</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">fieldError.id</span><span class="jsdoc-syntax">);
340                 </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
341                     </span><span class="jsdoc-var">f.markInvalid</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">fieldError.msg</span><span class="jsdoc-syntax">);
342                 }
343             }
344         }</span><span class="jsdoc-keyword">else</span><span class="jsdoc-syntax">{
345             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">field</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">;
346             </span><span class="jsdoc-keyword">for</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">id </span><span class="jsdoc-keyword">in </span><span class="jsdoc-var">errors</span><span class="jsdoc-syntax">){
347                 </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">typeof </span><span class="jsdoc-var">errors</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">] != </span><span class="jsdoc-string">'function' </span><span class="jsdoc-syntax">&amp;&amp; (</span><span class="jsdoc-var">field </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.findField</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">))){
348                     </span><span class="jsdoc-var">field.markInvalid</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">errors</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">]);
349                 }
350             }
351         }
352         </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms </span><span class="jsdoc-syntax">|| [], </span><span class="jsdoc-keyword">function </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">) {
353             </span><span class="jsdoc-var">f.markInvalid</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">errors</span><span class="jsdoc-syntax">);
354         });
355         
356         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
357     },
358
359     </span><span class="jsdoc-comment">/**
360      * Set values for fields in this form in bulk.
361      * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
362      * @return {BasicForm} this
363      */
364     </span><span class="jsdoc-var">setValues </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">){
365         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">values </span><span class="jsdoc-keyword">instanceof </span><span class="jsdoc-var">Array</span><span class="jsdoc-syntax">){ </span><span class="jsdoc-comment">// array of objects
366             </span><span class="jsdoc-keyword">for</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= 0, </span><span class="jsdoc-var">len </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">values.length</span><span class="jsdoc-syntax">; </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">&lt; </span><span class="jsdoc-var">len</span><span class="jsdoc-syntax">; </span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">++){
367                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">v </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">];
368                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">f </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.findField</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">v.id</span><span class="jsdoc-syntax">);
369                 </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
370                     </span><span class="jsdoc-var">f.setValue</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">v.value</span><span class="jsdoc-syntax">);
371                     </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.trackResetOnLoad</span><span class="jsdoc-syntax">){
372                         </span><span class="jsdoc-var">f.originalValue </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">f.getValue</span><span class="jsdoc-syntax">();
373                     }
374                 }
375             }
376         }</span><span class="jsdoc-keyword">else</span><span class="jsdoc-syntax">{ </span><span class="jsdoc-comment">// object hash
377             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">field</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">;
378             </span><span class="jsdoc-keyword">for</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">id </span><span class="jsdoc-keyword">in </span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">){
379                 </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">typeof </span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">] != </span><span class="jsdoc-string">'function' </span><span class="jsdoc-syntax">&amp;&amp; (</span><span class="jsdoc-var">field </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.findField</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">))){
380                     
381                     </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">field.setFromData </span><span class="jsdoc-syntax">&amp;&amp; 
382                         </span><span class="jsdoc-var">field.valueField </span><span class="jsdoc-syntax">&amp;&amp; 
383                         </span><span class="jsdoc-var">field.displayField </span><span class="jsdoc-syntax">&amp;&amp;
384                         </span><span class="jsdoc-comment">// combos' with local stores can 
385                         // be queried via setValue()
386                         // to set their value..
387                         </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">field.store </span><span class="jsdoc-syntax">&amp;&amp; !</span><span class="jsdoc-var">field.store.isLocal</span><span class="jsdoc-syntax">)
388                         ) {
389                         </span><span class="jsdoc-comment">// it's a combo
390                         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">sd </span><span class="jsdoc-syntax">= { };
391                         </span><span class="jsdoc-var">sd</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">field.valueField</span><span class="jsdoc-syntax">] = </span><span class="jsdoc-keyword">typeof</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">field.hiddenName</span><span class="jsdoc-syntax">]) == </span><span class="jsdoc-string">'undefined' </span><span class="jsdoc-syntax">? </span><span class="jsdoc-string">'' </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">field.hiddenName</span><span class="jsdoc-syntax">];
392                         </span><span class="jsdoc-var">sd</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">field.displayField</span><span class="jsdoc-syntax">] = </span><span class="jsdoc-keyword">typeof</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">field.name</span><span class="jsdoc-syntax">]) == </span><span class="jsdoc-string">'undefined' </span><span class="jsdoc-syntax">? </span><span class="jsdoc-string">'' </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">field.name</span><span class="jsdoc-syntax">];
393                         </span><span class="jsdoc-var">field.setFromData</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">sd</span><span class="jsdoc-syntax">);
394                         
395                     } </span><span class="jsdoc-keyword">else </span><span class="jsdoc-syntax">{
396                         </span><span class="jsdoc-var">field.setValue</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">id</span><span class="jsdoc-syntax">]);
397                     }
398                     
399                     
400                     </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.trackResetOnLoad</span><span class="jsdoc-syntax">){
401                         </span><span class="jsdoc-var">field.originalValue </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">field.getValue</span><span class="jsdoc-syntax">();
402                     }
403                 }
404             }
405         }
406          
407         </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms </span><span class="jsdoc-syntax">|| [], </span><span class="jsdoc-keyword">function </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">) {
408             </span><span class="jsdoc-var">f.setValues</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">values</span><span class="jsdoc-syntax">);
409         });
410                 
411         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
412     },
413
414     </span><span class="jsdoc-comment">/**
415      * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
416      * they are returned as an array.
417      * @param {Boolean} asString
418      * @return {Object}
419      */
420     </span><span class="jsdoc-var">getValues </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">asString</span><span class="jsdoc-syntax">){
421         </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms</span><span class="jsdoc-syntax">) {
422             </span><span class="jsdoc-comment">// copy values from the child forms
423             </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms</span><span class="jsdoc-syntax">, </span><span class="jsdoc-keyword">function </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">) {
424                 </span><span class="jsdoc-var">this.setValues</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.getValues</span><span class="jsdoc-syntax">());
425             }, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">);
426         }
427         
428         
429         
430         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">fs </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">Roo.lib.Ajax.serializeForm</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.el.dom</span><span class="jsdoc-syntax">);
431         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">asString </span><span class="jsdoc-syntax">=== </span><span class="jsdoc-keyword">true</span><span class="jsdoc-syntax">){
432             </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">fs</span><span class="jsdoc-syntax">;
433         }
434         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">Roo.urlDecode</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">fs</span><span class="jsdoc-syntax">);
435     },
436
437     </span><span class="jsdoc-comment">/**
438      * Clears all invalid messages in this form.
439      * @return {BasicForm} this
440      */
441     </span><span class="jsdoc-var">clearInvalid </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(){
442         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
443            </span><span class="jsdoc-var">f.clearInvalid</span><span class="jsdoc-syntax">();
444         });
445         
446         </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms </span><span class="jsdoc-syntax">|| [], </span><span class="jsdoc-keyword">function </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">) {
447             </span><span class="jsdoc-var">f.clearInvalid</span><span class="jsdoc-syntax">();
448         });
449         
450         
451         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
452     },
453
454     </span><span class="jsdoc-comment">/**
455      * Resets this form.
456      * @return {BasicForm} this
457      */
458     </span><span class="jsdoc-var">reset </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(){
459         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
460             </span><span class="jsdoc-var">f.reset</span><span class="jsdoc-syntax">();
461         });
462         
463         </span><span class="jsdoc-var">Roo.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.childForms </span><span class="jsdoc-syntax">|| [], </span><span class="jsdoc-keyword">function </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">) {
464             </span><span class="jsdoc-var">f.reset</span><span class="jsdoc-syntax">();
465         });
466        
467         
468         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
469     },
470
471     </span><span class="jsdoc-comment">/**
472      * Add Roo.form components to this form.
473      * @param {Field} field1
474      * @param {Field} field2 (optional)
475      * @param {Field} etc (optional)
476      * @return {BasicForm} this
477      */
478     </span><span class="jsdoc-var">add </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(){
479         </span><span class="jsdoc-var">this.items.addAll</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Array.prototype.slice.call</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">arguments</span><span class="jsdoc-syntax">, 0));
480         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
481     },
482
483
484     </span><span class="jsdoc-comment">/**
485      * Removes a field from the items collection (does NOT remove its markup).
486      * @param {Field} field
487      * @return {BasicForm} this
488      */
489     </span><span class="jsdoc-var">remove </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">field</span><span class="jsdoc-syntax">){
490         </span><span class="jsdoc-var">this.items.remove</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">field</span><span class="jsdoc-syntax">);
491         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
492     },
493
494     </span><span class="jsdoc-comment">/**
495      * Looks at the fields in this form, checks them for an id attribute,
496      * and calls applyTo on the existing dom element with that id.
497      * @return {BasicForm} this
498      */
499     </span><span class="jsdoc-var">render </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(){
500         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
501             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.isFormField </span><span class="jsdoc-syntax">&amp;&amp; !</span><span class="jsdoc-var">f.rendered </span><span class="jsdoc-syntax">&amp;&amp; </span><span class="jsdoc-var">document.getElementById</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.id</span><span class="jsdoc-syntax">)){ </span><span class="jsdoc-comment">// if the element exists
502                 </span><span class="jsdoc-var">f.applyTo</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f.id</span><span class="jsdoc-syntax">);
503             }
504         });
505         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
506     },
507
508     </span><span class="jsdoc-comment">/**
509      * Calls {@link Ext#apply} for all fields in this form with the passed object.
510      * @param {Object} values
511      * @return {BasicForm} this
512      */
513     </span><span class="jsdoc-var">applyToFields </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">){
514         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
515            </span><span class="jsdoc-var">Roo.apply</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">);
516         });
517         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
518     },
519
520     </span><span class="jsdoc-comment">/**
521      * Calls {@link Ext#applyIf} for all field in this form with the passed object.
522      * @param {Object} values
523      * @return {BasicForm} this
524      */
525     </span><span class="jsdoc-var">applyIfToFields </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">){
526         </span><span class="jsdoc-var">this.items.each</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">){
527            </span><span class="jsdoc-var">Roo.applyIf</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">f</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">o</span><span class="jsdoc-syntax">);
528         });
529         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
530     }
531 });
532
533 </span><span class="jsdoc-comment">// back compat
534 </span><span class="jsdoc-var">Roo.BasicForm </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">Roo.form.BasicForm</span><span class="jsdoc-syntax">;</span></code></body></html>