tvheadend/vendor/ext-3.4.1/docs/source/BasicForm.html
Adam Sutton bafcfff42d webui: restructure webui/extjs source files
I want to keep the 3rd-party packages away from the main source
where possible.
2013-06-03 17:11:01 +01:00

824 lines
36 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js"><span id='Ext-form-BasicForm-method-constructor'><span id='Ext-form-BasicForm'>/**
</span></span> * @class Ext.form.BasicForm
* @extends Ext.util.Observable
* &lt;p&gt;Encapsulates the DOM &amp;lt;form&gt; element at the heart of the {@link Ext.form.FormPanel FormPanel} class, and provides
* input field management, validation, submission, and form loading services.&lt;/p&gt;
* &lt;p&gt;By default, Ext Forms are submitted through Ajax, using an instance of {@link Ext.form.Action.Submit}.
* To enable normal browser submission of an Ext Form, use the {@link #standardSubmit} config option.&lt;/p&gt;
* &lt;p&gt;&lt;b&gt;&lt;u&gt;File Uploads&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
* &lt;p&gt;{@link #fileUpload File uploads} are not performed using Ajax submission, that
* is they are &lt;b&gt;not&lt;/b&gt; performed using XMLHttpRequests. Instead the form is submitted in the standard
* manner with the DOM &lt;tt&gt;&amp;lt;form&gt;&lt;/tt&gt; element temporarily modified to have its
* &lt;a href=&quot;http://www.w3.org/TR/REC-html40/present/frames.html#adef-target&quot;&gt;target&lt;/a&gt; set to refer
* to a dynamically generated, hidden &lt;tt&gt;&amp;lt;iframe&gt;&lt;/tt&gt; which is inserted into the document
* but removed after the return data has been gathered.&lt;/p&gt;
* &lt;p&gt;The server response is parsed by the browser to create the document for the IFRAME. If the
* server is using JSON to send the return object, then the
* &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17&quot;&gt;Content-Type&lt;/a&gt; header
* must be set to &quot;text/html&quot; in order to tell the browser to insert the text unchanged into the document body.&lt;/p&gt;
* &lt;p&gt;Characters which are significant to an HTML parser must be sent as HTML entities, so encode
* &quot;&amp;lt;&quot; as &quot;&amp;amp;lt;&quot;, &quot;&amp;amp;&quot; as &quot;&amp;amp;amp;&quot; etc.&lt;/p&gt;
* &lt;p&gt;The response text is retrieved from the document, and a fake XMLHttpRequest object
* is created containing a &lt;tt&gt;responseText&lt;/tt&gt; property in order to conform to the
* requirements of event handlers and callbacks.&lt;/p&gt;
* &lt;p&gt;Be aware that file upload packets are sent with the content type &lt;a href=&quot;http://www.faqs.org/rfcs/rfc2388.html&quot;&gt;multipart/form&lt;/a&gt;
* and some server technologies (notably JEE) may require some custom processing in order to
* retrieve parameter names and parameter values from the packet content.&lt;/p&gt;
* @constructor
* @param {Mixed} el The form element or its id
* @param {Object} config Configuration options
*/
Ext.form.BasicForm = Ext.extend(Ext.util.Observable, {
constructor: function(el, config){
Ext.apply(this, config);
if(Ext.isString(this.paramOrder)){
this.paramOrder = this.paramOrder.split(/[\s,|]/);
}
<span id='Ext-form-BasicForm-property-items'> /**
</span> * A {@link Ext.util.MixedCollection MixedCollection} containing all the Ext.form.Fields in this form.
* @type MixedCollection
* @property items
*/
this.items = new Ext.util.MixedCollection(false, function(o){
return o.getItemId();
});
this.addEvents(
<span id='Ext-form-BasicForm-event-beforeaction'> /**
</span> * @event beforeaction
* Fires before any action is performed. Return false to cancel the action.
* @param {Form} this
* @param {Action} action The {@link Ext.form.Action} to be performed
*/
'beforeaction',
<span id='Ext-form-BasicForm-event-actionfailed'> /**
</span> * @event actionfailed
* Fires when an action fails.
* @param {Form} this
* @param {Action} action The {@link Ext.form.Action} that failed
*/
'actionfailed',
<span id='Ext-form-BasicForm-event-actioncomplete'> /**
</span> * @event actioncomplete
* Fires when an action is completed.
* @param {Form} this
* @param {Action} action The {@link Ext.form.Action} that completed
*/
'actioncomplete'
);
if(el){
this.initEl(el);
}
Ext.form.BasicForm.superclass.constructor.call(this);
},
<span id='Ext-form-BasicForm-cfg-method'> /**
</span> * @cfg {String} method
* The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
*/
<span id='Ext-form-BasicForm-cfg-reader'> /**
</span> * @cfg {DataReader} reader
* An Ext.data.DataReader (e.g. {@link Ext.data.XmlReader}) to be used to read
* data when executing 'load' actions. This is optional as there is built-in
* support for processing JSON. For additional information on using an XMLReader
* see the example provided in examples/form/xml-form.html.
*/
<span id='Ext-form-BasicForm-cfg-errorReader'> /**
</span> * @cfg {DataReader} errorReader
* &lt;p&gt;An Ext.data.DataReader (e.g. {@link Ext.data.XmlReader}) to be used to
* read field error messages returned from 'submit' actions. This is optional
* as there is built-in support for processing JSON.&lt;/p&gt;
* &lt;p&gt;The Records which provide messages for the invalid Fields must use the
* Field name (or id) as the Record ID, and must contain a field called 'msg'
* which contains the error message.&lt;/p&gt;
* &lt;p&gt;The errorReader does not have to be a full-blown implementation of a
* DataReader. It simply needs to implement a &lt;tt&gt;read(xhr)&lt;/tt&gt; function
* which returns an Array of Records in an object with the following
* structure:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
{
records: recordArray
}
&lt;/code&gt;&lt;/pre&gt;
*/
<span id='Ext-form-BasicForm-cfg-url'> /**
</span> * @cfg {String} url
* The URL to use for form actions if one isn't supplied in the
* &lt;code&gt;{@link #doAction doAction} options&lt;/code&gt;.
*/
<span id='Ext-form-BasicForm-cfg-fileUpload'> /**
</span> * @cfg {Boolean} fileUpload
* Set to true if this form is a file upload.
* &lt;p&gt;File uploads are not performed using normal 'Ajax' techniques, that is they are &lt;b&gt;not&lt;/b&gt;
* performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the
* DOM &lt;tt&gt;&amp;lt;form&gt;&lt;/tt&gt; element temporarily modified to have its
* &lt;a href=&quot;http://www.w3.org/TR/REC-html40/present/frames.html#adef-target&quot;&gt;target&lt;/a&gt; set to refer
* to a dynamically generated, hidden &lt;tt&gt;&amp;lt;iframe&gt;&lt;/tt&gt; which is inserted into the document
* but removed after the return data has been gathered.&lt;/p&gt;
* &lt;p&gt;The server response is parsed by the browser to create the document for the IFRAME. If the
* server is using JSON to send the return object, then the
* &lt;a href=&quot;http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17&quot;&gt;Content-Type&lt;/a&gt; header
* must be set to &quot;text/html&quot; in order to tell the browser to insert the text unchanged into the document body.&lt;/p&gt;
* &lt;p&gt;Characters which are significant to an HTML parser must be sent as HTML entities, so encode
* &quot;&amp;lt;&quot; as &quot;&amp;amp;lt;&quot;, &quot;&amp;amp;&quot; as &quot;&amp;amp;amp;&quot; etc.&lt;/p&gt;
* &lt;p&gt;The response text is retrieved from the document, and a fake XMLHttpRequest object
* is created containing a &lt;tt&gt;responseText&lt;/tt&gt; property in order to conform to the
* requirements of event handlers and callbacks.&lt;/p&gt;
* &lt;p&gt;Be aware that file upload packets are sent with the content type &lt;a href=&quot;http://www.faqs.org/rfcs/rfc2388.html&quot;&gt;multipart/form&lt;/a&gt;
* and some server technologies (notably JEE) may require some custom processing in order to
* retrieve parameter names and parameter values from the packet content.&lt;/p&gt;
*/
<span id='Ext-form-BasicForm-cfg-baseParams'> /**
</span> * @cfg {Object} baseParams
* &lt;p&gt;Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.&lt;/p&gt;
* &lt;p&gt;Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode}.&lt;/p&gt;
*/
<span id='Ext-form-BasicForm-cfg-timeout'> /**
</span> * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
*/
timeout: 30,
<span id='Ext-form-BasicForm-cfg-api'> /**
</span> * @cfg {Object} api (Optional) If specified load and submit actions will be handled
* with {@link Ext.form.Action.DirectLoad} and {@link Ext.form.Action.DirectSubmit}.
* Methods which have been imported by Ext.Direct can be specified here to load and submit
* forms.
* Such as the following:&lt;pre&gt;&lt;code&gt;
api: {
load: App.ss.MyProfile.load,
submit: App.ss.MyProfile.submit
}
&lt;/code&gt;&lt;/pre&gt;
* &lt;p&gt;Load actions can use &lt;code&gt;{@link #paramOrder}&lt;/code&gt; or &lt;code&gt;{@link #paramsAsHash}&lt;/code&gt;
* to customize how the load method is invoked.
* Submit actions will always use a standard form submit. The formHandler configuration must
* be set on the associated server-side method which has been imported by Ext.Direct&lt;/p&gt;
*/
<span id='Ext-form-BasicForm-cfg-paramOrder'> /**
</span> * @cfg {Array/String} paramOrder &lt;p&gt;A list of params to be executed server side.
* Defaults to &lt;tt&gt;undefined&lt;/tt&gt;. Only used for the &lt;code&gt;{@link #api}&lt;/code&gt;
* &lt;code&gt;load&lt;/code&gt; configuration.&lt;/p&gt;
* &lt;br&gt;&lt;p&gt;Specify the params in the order in which they must be executed on the
* server-side as either (1) an Array of String values, or (2) a String of params
* delimited by either whitespace, comma, or pipe. For example,
* any of the following would be acceptable:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
paramOrder: ['param1','param2','param3']
paramOrder: 'param1 param2 param3'
paramOrder: 'param1,param2,param3'
paramOrder: 'param1|param2|param'
&lt;/code&gt;&lt;/pre&gt;
*/
paramOrder: undefined,
<span id='Ext-form-BasicForm-cfg-paramsAsHash'> /**
</span> * @cfg {Boolean} paramsAsHash Only used for the &lt;code&gt;{@link #api}&lt;/code&gt;
* &lt;code&gt;load&lt;/code&gt; configuration. Send parameters as a collection of named
* arguments (defaults to &lt;tt&gt;false&lt;/tt&gt;). Providing a
* &lt;tt&gt;{@link #paramOrder}&lt;/tt&gt; nullifies this configuration.
*/
paramsAsHash: false,
<span id='Ext-form-BasicForm-cfg-waitTitle'> /**
</span> * @cfg {String} waitTitle
* The default title to show for the waiting message box (defaults to &lt;tt&gt;'Please Wait...'&lt;/tt&gt;)
*/
waitTitle: 'Please Wait...',
<span id='Ext-form-BasicForm-property-activeAction'> // private
</span> activeAction : null,
<span id='Ext-form-BasicForm-cfg-trackResetOnLoad'> /**
</span> * @cfg {Boolean} trackResetOnLoad If set to &lt;tt&gt;true&lt;/tt&gt;, {@link #reset}() resets to the last loaded
* or {@link #setValues}() data instead of when the form was first created. Defaults to &lt;tt&gt;false&lt;/tt&gt;.
*/
trackResetOnLoad : false,
<span id='Ext-form-BasicForm-cfg-standardSubmit'> /**
</span> * @cfg {Boolean} standardSubmit
* &lt;p&gt;If set to &lt;tt&gt;true&lt;/tt&gt;, standard HTML form submits are used instead
* of XHR (Ajax) style form submissions. Defaults to &lt;tt&gt;false&lt;/tt&gt;.&lt;/p&gt;
* &lt;br&gt;&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; When using &lt;code&gt;standardSubmit&lt;/code&gt;, the
* &lt;code&gt;options&lt;/code&gt; to &lt;code&gt;{@link #submit}&lt;/code&gt; are ignored because
* Ext's Ajax infrastracture is bypassed. To pass extra parameters (e.g.
* &lt;code&gt;baseParams&lt;/code&gt; and &lt;code&gt;params&lt;/code&gt;), utilize hidden fields
* to submit extra data, for example:&lt;/p&gt;
* &lt;pre&gt;&lt;code&gt;
new Ext.FormPanel({
standardSubmit: true,
baseParams: {
foo: 'bar'
},
{@link url}: 'myProcess.php',
items: [{
xtype: 'textfield',
name: 'userName'
}],
buttons: [{
text: 'Save',
handler: function(){
var fp = this.ownerCt.ownerCt,
form = fp.getForm();
if (form.isValid()) {
// check if there are baseParams and if
// hiddent items have been added already
if (fp.baseParams &amp;&amp; !fp.paramsAdded) {
// add hidden items for all baseParams
for (i in fp.baseParams) {
fp.add({
xtype: 'hidden',
name: i,
value: fp.baseParams[i]
});
}
fp.doLayout();
// set a custom flag to prevent re-adding
fp.paramsAdded = true;
}
form.{@link #submit}();
}
}
}]
});
* &lt;/code&gt;&lt;/pre&gt;
*/
<span id='Ext-form-BasicForm-property-waitMsgTarget'> /**
</span> * By default wait messages are displayed with Ext.MessageBox.wait. You can target a specific
* element by passing it or its id or mask the form itself by passing in true.
* @type Mixed
* @property waitMsgTarget
*/
<span id='Ext-form-BasicForm-method-initEl'> // private
</span> initEl : function(el){
this.el = Ext.get(el);
this.id = this.el.id || Ext.id();
if(!this.standardSubmit){
this.el.on('submit', this.onSubmit, this);
}
this.el.addClass('x-form');
},
<span id='Ext-form-BasicForm-method-getEl'> /**
</span> * Get the HTML form Element
* @return Ext.Element
*/
getEl: function(){
return this.el;
},
<span id='Ext-form-BasicForm-method-onSubmit'> // private
</span> onSubmit : function(e){
e.stopEvent();
},
<span id='Ext-form-BasicForm-method-destroy'> /**
</span> * Destroys this object.
* @private
* @param {Boolean} bound true if the object is bound to a form panel. If this is the case
* the FormPanel will take care of destroying certain things, so we're just doubling up.
*/
destroy: function(bound){
if(bound !== true){
this.items.each(function(f){
Ext.destroy(f);
});
Ext.destroy(this.el);
}
this.items.clear();
this.purgeListeners();
},
<span id='Ext-form-BasicForm-method-isValid'> /**
</span> * Returns true if client-side validation on the form is successful.
* @return Boolean
*/
isValid : function(){
var valid = true;
this.items.each(function(f){
if(!f.validate()){
valid = false;
}
});
return valid;
},
<span id='Ext-form-BasicForm-method-isDirty'> /**
</span> * &lt;p&gt;Returns true if any fields in this form have changed from their original values.&lt;/p&gt;
* &lt;p&gt;Note that if this BasicForm was configured with {@link #trackResetOnLoad} then the
* Fields' &lt;i&gt;original values&lt;/i&gt; are updated when the values are loaded by {@link #setValues}
* or {@link #loadRecord}.&lt;/p&gt;
* @return Boolean
*/
isDirty : function(){
var dirty = false;
this.items.each(function(f){
if(f.isDirty()){
dirty = true;
return false;
}
});
return dirty;
},
<span id='Ext-form-BasicForm-method-doAction'> /**
</span> * Performs a predefined action ({@link Ext.form.Action.Submit} or
* {@link Ext.form.Action.Load}) or a custom extension of {@link Ext.form.Action}
* to perform application-specific processing.
* @param {String/Object} actionName The name of the predefined action type,
* or instance of {@link Ext.form.Action} to perform.
* @param {Object} options (optional) The options to pass to the {@link Ext.form.Action}.
* All of the config options listed below are supported by both the
* {@link Ext.form.Action.Submit submit} and {@link Ext.form.Action.Load load}
* actions unless otherwise noted (custom actions could also accept
* other config options):&lt;ul&gt;
*
* &lt;li&gt;&lt;b&gt;url&lt;/b&gt; : String&lt;div class=&quot;sub-desc&quot;&gt;The url for the action (defaults
* to the form's {@link #url}.)&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;method&lt;/b&gt; : String&lt;div class=&quot;sub-desc&quot;&gt;The form method to use (defaults
* to the form's method, or POST if not defined)&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;params&lt;/b&gt; : String/Object&lt;div class=&quot;sub-desc&quot;&gt;&lt;p&gt;The params to pass
* (defaults to the form's baseParams, or none if not defined)&lt;/p&gt;
* &lt;p&gt;Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode}.&lt;/p&gt;&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;headers&lt;/b&gt; : Object&lt;div class=&quot;sub-desc&quot;&gt;Request headers to set for the action
* (defaults to the form's default headers)&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;success&lt;/b&gt; : Function&lt;div class=&quot;sub-desc&quot;&gt;The callback that will
* be invoked after a successful response (see top of
* {@link Ext.form.Action.Submit submit} and {@link Ext.form.Action.Load load}
* for a description of what constitutes a successful response).
* The function is passed the following parameters:&lt;ul&gt;
* &lt;li&gt;&lt;tt&gt;form&lt;/tt&gt; : Ext.form.BasicForm&lt;div class=&quot;sub-desc&quot;&gt;The form that requested the action&lt;/div&gt;&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;action&lt;/tt&gt; : The {@link Ext.form.Action Action} object which performed the operation.
* &lt;div class=&quot;sub-desc&quot;&gt;The action object contains these properties of interest:&lt;ul&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#response response}&lt;/tt&gt;&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#result result}&lt;/tt&gt; : interrogate for custom postprocessing&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#type type}&lt;/tt&gt;&lt;/li&gt;
* &lt;/ul&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;failure&lt;/b&gt; : Function&lt;div class=&quot;sub-desc&quot;&gt;The callback that will be invoked after a
* failed transaction attempt. The function is passed the following parameters:&lt;ul&gt;
* &lt;li&gt;&lt;tt&gt;form&lt;/tt&gt; : The {@link Ext.form.BasicForm} that requested the action.&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;action&lt;/tt&gt; : The {@link Ext.form.Action Action} object which performed the operation.
* &lt;div class=&quot;sub-desc&quot;&gt;The action object contains these properties of interest:&lt;ul&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#failureType failureType}&lt;/tt&gt;&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#response response}&lt;/tt&gt;&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#result result}&lt;/tt&gt; : interrogate for custom postprocessing&lt;/li&gt;
* &lt;li&gt;&lt;tt&gt;{@link Ext.form.Action#type type}&lt;/tt&gt;&lt;/li&gt;
* &lt;/ul&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;scope&lt;/b&gt; : Object&lt;div class=&quot;sub-desc&quot;&gt;The scope in which to call the
* callback functions (The &lt;tt&gt;this&lt;/tt&gt; reference for the callback functions).&lt;/div&gt;&lt;/li&gt;
*
* &lt;li&gt;&lt;b&gt;clientValidation&lt;/b&gt; : Boolean&lt;div class=&quot;sub-desc&quot;&gt;Submit Action only.
* Determines whether a Form's fields are validated in a final call to
* {@link Ext.form.BasicForm#isValid isValid} prior to submission. Set to &lt;tt&gt;false&lt;/tt&gt;
* to prevent this. If undefined, pre-submission field validation is performed.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
*
* @return {BasicForm} this
*/
doAction : function(action, options){
if(Ext.isString(action)){
action = new Ext.form.Action.ACTION_TYPES[action](this, options);
}
if(this.fireEvent('beforeaction', this, action) !== false){
this.beforeAction(action);
action.run.defer(100, action);
}
return this;
},
<span id='Ext-form-BasicForm-method-submit'> /**
</span> * Shortcut to {@link #doAction do} a {@link Ext.form.Action.Submit submit action}.
* @param {Object} options The options to pass to the action (see {@link #doAction} for details).&lt;br&gt;
* &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; this is ignored when using the {@link #standardSubmit} option.&lt;/p&gt;
* &lt;p&gt;The following code:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
myFormPanel.getForm().submit({
clientValidation: true,
url: 'updateConsignment.php',
params: {
newStatus: 'delivered'
},
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
break;
case Ext.form.Action.CONNECT_FAILURE:
Ext.Msg.alert('Failure', 'Ajax communication failed');
break;
case Ext.form.Action.SERVER_INVALID:
Ext.Msg.alert('Failure', action.result.msg);
}
}
});
&lt;/code&gt;&lt;/pre&gt;
* would process the following server response for a successful submission:&lt;pre&gt;&lt;code&gt;
{
&quot;success&quot;:true, // note this is Boolean, not string
&quot;msg&quot;:&quot;Consignment updated&quot;
}
&lt;/code&gt;&lt;/pre&gt;
* and the following server response for a failed submission:&lt;pre&gt;&lt;code&gt;
{
&quot;success&quot;:false, // note this is Boolean, not string
&quot;msg&quot;:&quot;You do not have permission to perform this operation&quot;
}
&lt;/code&gt;&lt;/pre&gt;
* @return {BasicForm} this
*/
submit : function(options){
options = options || {};
if(this.standardSubmit){
var v = options.clientValidation === false || this.isValid();
if(v){
var el = this.el.dom;
if(this.url &amp;&amp; Ext.isEmpty(el.action)){
el.action = this.url;
}
el.submit();
}
return v;
}
var submitAction = String.format('{0}submit', this.api ? 'direct' : '');
this.doAction(submitAction, options);
return this;
},
<span id='Ext-form-BasicForm-method-load'> /**
</span> * Shortcut to {@link #doAction do} a {@link Ext.form.Action.Load load action}.
* @param {Object} options The options to pass to the action (see {@link #doAction} for details)
* @return {BasicForm} this
*/
load : function(options){
var loadAction = String.format('{0}load', this.api ? 'direct' : '');
this.doAction(loadAction, options);
return this;
},
<span id='Ext-form-BasicForm-method-updateRecord'> /**
</span> * Persists the values in this form into the passed {@link Ext.data.Record} object in a beginEdit/endEdit block.
* @param {Record} record The record to edit
* @return {BasicForm} this
*/
updateRecord : function(record){
record.beginEdit();
var fs = record.fields,
field,
value;
fs.each(function(f){
field = this.findField(f.name);
if(field){
value = field.getValue();
if (Ext.type(value) !== false &amp;&amp; value.getGroupValue) {
value = value.getGroupValue();
} else if ( field.eachItem ) {
value = [];
field.eachItem(function(item){
value.push(item.getValue());
});
}
record.set(f.name, value);
}
}, this);
record.endEdit();
return this;
},
<span id='Ext-form-BasicForm-method-loadRecord'> /**
</span> * Loads an {@link Ext.data.Record} into this form by calling {@link #setValues} with the
* {@link Ext.data.Record#data record data}.
* See also {@link #trackResetOnLoad}.
* @param {Record} record The record to load
* @return {BasicForm} this
*/
loadRecord : function(record){
this.setValues(record.data);
return this;
},
<span id='Ext-form-BasicForm-method-beforeAction'> // private
</span> beforeAction : function(action){
// Call HtmlEditor's syncValue before actions
this.items.each(function(f){
if(f.isFormField &amp;&amp; f.syncValue){
f.syncValue();
}
});
var o = action.options;
if(o.waitMsg){
if(this.waitMsgTarget === true){
this.el.mask(o.waitMsg, 'x-mask-loading');
}else if(this.waitMsgTarget){
this.waitMsgTarget = Ext.get(this.waitMsgTarget);
this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');
}else{
Ext.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle);
}
}
},
<span id='Ext-form-BasicForm-method-afterAction'> // private
</span> afterAction : function(action, success){
this.activeAction = null;
var o = action.options;
if(o.waitMsg){
if(this.waitMsgTarget === true){
this.el.unmask();
}else if(this.waitMsgTarget){
this.waitMsgTarget.unmask();
}else{
Ext.MessageBox.updateProgress(1);
Ext.MessageBox.hide();
}
}
if(success){
if(o.reset){
this.reset();
}
Ext.callback(o.success, o.scope, [this, action]);
this.fireEvent('actioncomplete', this, action);
}else{
Ext.callback(o.failure, o.scope, [this, action]);
this.fireEvent('actionfailed', this, action);
}
},
<span id='Ext-form-BasicForm-method-findField'> /**
</span> * Find a {@link Ext.form.Field} in this form.
* @param {String} id The value to search for (specify either a {@link Ext.Component#id id},
* {@link Ext.grid.Column#dataIndex dataIndex}, {@link Ext.form.Field#getName name or hiddenName}).
* @return Field
*/
findField : function(id) {
var field = this.items.get(id);
if (!Ext.isObject(field)) {
//searches for the field corresponding to the given id. Used recursively for composite fields
var findMatchingField = function(f) {
if (f.isFormField) {
if (f.dataIndex == id || f.id == id || f.getName() == id) {
field = f;
return false;
} else if (f.isComposite) {
return f.items.each(findMatchingField);
} else if (f instanceof Ext.form.CheckboxGroup &amp;&amp; f.rendered) {
return f.eachItem(findMatchingField);
}
}
};
this.items.each(findMatchingField);
}
return field || null;
},
<span id='Ext-form-BasicForm-method-markInvalid'> /**
</span> * Mark fields in this form invalid in bulk.
* @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
* @return {BasicForm} this
*/
markInvalid : function(errors){
if (Ext.isArray(errors)) {
for(var i = 0, len = errors.length; i &lt; len; i++){
var fieldError = errors[i];
var f = this.findField(fieldError.id);
if(f){
f.markInvalid(fieldError.msg);
}
}
} else {
var field, id;
for(id in errors){
if(!Ext.isFunction(errors[id]) &amp;&amp; (field = this.findField(id))){
field.markInvalid(errors[id]);
}
}
}
return this;
},
<span id='Ext-form-BasicForm-method-setValues'> /**
</span> * Set values for fields in this form in bulk.
* @param {Array/Object} values Either an array in the form:&lt;pre&gt;&lt;code&gt;
[{id:'clientName', value:'Fred. Olsen Lines'},
{id:'portOfLoading', value:'FXT'},
{id:'portOfDischarge', value:'OSL'} ]&lt;/code&gt;&lt;/pre&gt;
* or an object hash of the form:&lt;pre&gt;&lt;code&gt;
{
clientName: 'Fred. Olsen Lines',
portOfLoading: 'FXT',
portOfDischarge: 'OSL'
}&lt;/code&gt;&lt;/pre&gt;
* @return {BasicForm} this
*/
setValues : function(values){
if(Ext.isArray(values)){ // array of objects
for(var i = 0, len = values.length; i &lt; len; i++){
var v = values[i];
var f = this.findField(v.id);
if(f){
f.setValue(v.value);
if(this.trackResetOnLoad){
f.originalValue = f.getValue();
}
}
}
}else{ // object hash
var field, id;
for(id in values){
if(!Ext.isFunction(values[id]) &amp;&amp; (field = this.findField(id))){
field.setValue(values[id]);
if(this.trackResetOnLoad){
field.originalValue = field.getValue();
}
}
}
}
return this;
},
<span id='Ext-form-BasicForm-method-getValues'> /**
</span> * &lt;p&gt;Returns the fields in this form as an object with key/value pairs as they would be submitted using a standard form submit.
* If multiple fields exist with the same name they are returned as an array.&lt;/p&gt;
* &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; The values are collected from all enabled HTML input elements within the form, &lt;u&gt;not&lt;/u&gt; from
* the Ext Field objects. This means that all returned values are Strings (or Arrays of Strings) and that the
* value can potentially be the emptyText of a field.&lt;/p&gt;
* @param {Boolean} asString (optional) Pass true to return the values as a string. (defaults to false, returning an Object)
* @return {String/Object}
*/
getValues : function(asString){
var fs = Ext.lib.Ajax.serializeForm(this.el.dom);
if(asString === true){
return fs;
}
return Ext.urlDecode(fs);
},
<span id='Ext-form-BasicForm-method-getFieldValues'> /**
</span> * Retrieves the fields in the form as a set of key/value pairs, using the {@link Ext.form.Field#getValue getValue()} method.
* If multiple fields exist with the same name they are returned as an array.
* @param {Boolean} dirtyOnly (optional) True to return only fields that are dirty.
* @return {Object} The values in the form
*/
getFieldValues : function(dirtyOnly){
var o = {},
n,
key,
val;
this.items.each(function(f) {
if (!f.disabled &amp;&amp; (dirtyOnly !== true || f.isDirty())) {
n = f.getName();
key = o[n];
val = f.getValue();
if(Ext.isDefined(key)){
if(Ext.isArray(key)){
o[n].push(val);
}else{
o[n] = [key, val];
}
}else{
o[n] = val;
}
}
});
return o;
},
<span id='Ext-form-BasicForm-method-clearInvalid'> /**
</span> * Clears all invalid messages in this form.
* @return {BasicForm} this
*/
clearInvalid : function(){
this.items.each(function(f){
f.clearInvalid();
});
return this;
},
<span id='Ext-form-BasicForm-method-reset'> /**
</span> * Resets this form.
* @return {BasicForm} this
*/
reset : function(){
this.items.each(function(f){
f.reset();
});
return this;
},
<span id='Ext-form-BasicForm-method-add'> /**
</span> * Add Ext.form Components to this form's Collection. This does not result in rendering of
* the passed Component, it just enables the form to validate Fields, and distribute values to
* Fields.
* &lt;p&gt;&lt;b&gt;You will not usually call this function. In order to be rendered, a Field must be added
* to a {@link Ext.Container Container}, usually an {@link Ext.form.FormPanel FormPanel}.
* The FormPanel to which the field is added takes care of adding the Field to the BasicForm's
* collection.&lt;/b&gt;&lt;/p&gt;
* @param {Field} field1
* @param {Field} field2 (optional)
* @param {Field} etc (optional)
* @return {BasicForm} this
*/
add : function(){
this.items.addAll(Array.prototype.slice.call(arguments, 0));
return this;
},
<span id='Ext-form-BasicForm-method-remove'> /**
</span> * Removes a field from the items collection (does NOT remove its markup).
* @param {Field} field
* @return {BasicForm} this
*/
remove : function(field){
this.items.remove(field);
return this;
},
<span id='Ext-form-BasicForm-method-cleanDestroyed'> /**
</span> * Removes all fields from the collection that have been destroyed.
*/
cleanDestroyed : function() {
this.items.filterBy(function(o) { return !!o.isDestroyed; }).each(this.remove, this);
},
<span id='Ext-form-BasicForm-method-render'> /**
</span> * Iterates through the {@link Ext.form.Field Field}s which have been {@link #add add}ed to this BasicForm,
* checks them for an id attribute, and calls {@link Ext.form.Field#applyToMarkup} on the existing dom element with that id.
* @return {BasicForm} this
*/
render : function(){
this.items.each(function(f){
if(f.isFormField &amp;&amp; !f.rendered &amp;&amp; document.getElementById(f.id)){ // if the element exists
f.applyToMarkup(f.id);
}
});
return this;
},
<span id='Ext-form-BasicForm-method-applyToFields'> /**
</span> * Calls {@link Ext#apply} for all fields in this form with the passed object.
* @param {Object} values
* @return {BasicForm} this
*/
applyToFields : function(o){
this.items.each(function(f){
Ext.apply(f, o);
});
return this;
},
<span id='Ext-form-BasicForm-method-applyIfToFields'> /**
</span> * Calls {@link Ext#applyIf} for all field in this form with the passed object.
* @param {Object} values
* @return {BasicForm} this
*/
applyIfToFields : function(o){
this.items.each(function(f){
Ext.applyIf(f, o);
});
return this;
},
<span id='Ext-form-BasicForm-method-callFieldMethod'> callFieldMethod : function(fnName, args){
</span> args = args || [];
this.items.each(function(f){
if(Ext.isFunction(f[fnName])){
f[fnName].apply(f, args);
}
});
return this;
}
});
// back compat
Ext.BasicForm = Ext.form.BasicForm;
</pre>
</body>
</html>