/* This file is part of Ext JS 3.4 Copyright (c) 2011-2013 Sencha Inc Contact: http://www.sencha.com/contact GNU General Public License Usage This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. Build date: 2013-04-03 15:07:25 */ Ext.data.JsonP.Ext_form_BasicForm({"alternateClassNames":[],"aliases":{},"enum":null,"parentMixins":[],"tagname":"class","subclasses":[],"extends":"Ext.util.Observable","uses":[],"html":"
Hierarchy
Ext.util.ObservableExt.form.BasicFormFiles
Encapsulates the DOM <form> element at the heart of the FormPanel class, and provides\ninput field management, validation, submission, and form loading services.
\n\n\nBy default, Ext Forms are submitted through Ajax, using an instance of Ext.form.Action.Submit.\nTo enable normal browser submission of an Ext Form, use the standardSubmit config option.
\n\n\nFile Uploads
\n\n\nFile uploads are not performed using Ajax submission, that\nis they are not performed using XMLHttpRequests. Instead the form is submitted in the standard\nmanner with the DOM <form> element temporarily modified to have its\ntarget set to refer\nto a dynamically generated, hidden <iframe> which is inserted into the document\nbut removed after the return data has been gathered.
\n\n\nThe server response is parsed by the browser to create the document for the IFRAME. If the\nserver is using JSON to send the return object, then the\nContent-Type header\nmust be set to \"text/html\" in order to tell the browser to insert the text unchanged into the document body.
\n\n\nCharacters which are significant to an HTML parser must be sent as HTML entities, so encode\n\"<\" as \"<\", \"&\" as \"&\" etc.
\n\n\nThe response text is retrieved from the document, and a fake XMLHttpRequest object\nis created containing a responseText property in order to conform to the\nrequirements of event handlers and callbacks.
\n\n\nBe aware that file upload packets are sent with the content type multipart/form\nand some server technologies (notably JEE) may require some custom processing in order to\nretrieve parameter names and parameter values from the packet content.
\n\n(Optional) If specified load and submit actions will be handled\nwith Ext.form.Action.DirectLoad and Ext.form.Action.DirectSubmit.\nMethods which have been imported by Ext.Direct can be specified here to load and submit\nforms.\nSuch as the following:
\n\napi: {\n load: App.ss.MyProfile.load,\n submit: App.ss.MyProfile.submit\n}\n
\n\n\nLoad actions can use paramOrder
or paramsAsHash
\nto customize how the load method is invoked.\nSubmit actions will always use a standard form submit. The formHandler configuration must\nbe set on the associated server-side method which has been imported by Ext.Direct
Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
\n\n\nParameters are encoded as standard HTTP parameters using Ext.urlEncode.
\n\nAn Ext.data.DataReader (e.g. Ext.data.XmlReader) to be used to\nread field error messages returned from 'submit' actions. This is optional\nas there is built-in support for processing JSON.
\n\n\nThe Records which provide messages for the invalid Fields must use the\nField name (or id) as the Record ID, and must contain a field called 'msg'\nwhich contains the error message.
\n\n\nThe errorReader does not have to be a full-blown implementation of a\nDataReader. It simply needs to implement a read(xhr) function\nwhich returns an Array of Records in an object with the following\nstructure:
\n\n\n{\n records: recordArray\n}\n
\n\nSet to true if this form is a file upload.
\n\nFile uploads are not performed using normal 'Ajax' techniques, that is they are not\nperformed using XMLHttpRequests. Instead the form is submitted in the standard manner with the\nDOM <form> element temporarily modified to have its\ntarget set to refer\nto a dynamically generated, hidden <iframe> which is inserted into the document\nbut removed after the return data has been gathered.
\n\n\nThe server response is parsed by the browser to create the document for the IFRAME. If the\nserver is using JSON to send the return object, then the\nContent-Type header\nmust be set to \"text/html\" in order to tell the browser to insert the text unchanged into the document body.
\n\n\nCharacters which are significant to an HTML parser must be sent as HTML entities, so encode\n\"<\" as \"<\", \"&\" as \"&\" etc.
\n\n\nThe response text is retrieved from the document, and a fake XMLHttpRequest object\nis created containing a responseText property in order to conform to the\nrequirements of event handlers and callbacks.
\n\n\nBe aware that file upload packets are sent with the content type multipart/form\nand some server technologies (notably JEE) may require some custom processing in order to\nretrieve parameter names and parameter values from the packet content.
\n\n(optional)
A config object containing one or more event handlers to be added to this\nobject during initialization. This should be a valid listeners config object as specified in the\naddListener example for attaching multiple handlers at once.
\n\nDOM events from ExtJs Components
\n\n\nWhile some ExtJs Component classes export selected DOM events (e.g. \"click\", \"mouseover\" etc), this\n\n\n
is usually only done when extra value can be added. For example the DataView's\nclick
event passing the node clicked on. To access DOM\nevents directly from a Component's HTMLElement, listeners must be added to the Element after the Component\nhas been rendered. A plugin can simplify this step:
// Plugin is configured with a listeners config object.\n// The Component is appended to the argument list of all handler functions.\nExt.DomObserver = Ext.extend(Object, {\n constructor: function(config) {\n this.listeners = config.listeners ? config.listeners : config;\n },\n\n // Component passes itself into plugin's init method\n init: function(c) {\n var p, l = this.listeners;\n for (p in l) {\n if (Ext.isFunction(l[p])) {\n l[p] = this.createHandler(l[p], c);\n } else {\n l[p].fn = this.createHandler(l[p].fn, c);\n }\n }\n\n // Add the listeners to the Element immediately following the render call\n c.render = c.render.createSequence(function() {\n var e = c.getEl();\n if (e) {\n e.on(l);\n }\n });\n },\n\n createHandler: function(fn, c) {\n return function(e) {\n fn.call(this, e, c);\n };\n }\n});\n\nvar combo = new Ext.form.ComboBox({\n\n // Collapse combo when its element is clicked on\n plugins: [ new Ext.DomObserver({\n click: function(evt, comp) {\n comp.collapse();\n }\n })],\n store: myStore,\n typeAhead: true,\n mode: 'local',\n triggerAction: 'all'\n});\n
\n\n\n\nThe request method to use (GET or POST) for form actions if one isn't supplied in the action options.
\nThe request method to use (GET or POST) for form actions if one isn't supplied in the action options.
\nA list of params to be executed server side.\nDefaults to undefined. Only used for the api
\nload
configuration.
Specify the params in the order in which they must be executed on the\n\n\n
server-side as either (1) an Array of String values, or (2) a String of params\ndelimited by either whitespace, comma, or pipe. For example,\nany of the following would be acceptable:
\n\nparamOrder: ['param1','param2','param3']\nparamOrder: 'param1 param2 param3'\nparamOrder: 'param1,param2,param3'\nparamOrder: 'param1|param2|param'\n
\n\nOnly used for the api
\nload
configuration. Send parameters as a collection of named\narguments (defaults to false). Providing a\nparamOrder nullifies this configuration.
Defaults to: false
An Ext.data.DataReader (e.g. Ext.data.XmlReader) to be used to read\ndata when executing 'load' actions. This is optional as there is built-in\nsupport for processing JSON. For additional information on using an XMLReader\nsee the example provided in examples/form/xml-form.html.
\nIf set to true, standard HTML form submits are used instead\nof XHR (Ajax) style form submissions. Defaults to false.
\n\n\nNote: When using standardSubmit
, the\n\n\n
options
to submit
are ignored because\nExt's Ajax infrastracture is bypassed. To pass extra parameters (e.g.\nbaseParams
and params
), utilize hidden fields\nto submit extra data, for example:
new Ext.FormPanel({\n standardSubmit: true,\n baseParams: {\n foo: 'bar'\n },\n url: 'myProcess.php',\n items: [{\n xtype: 'textfield',\n name: 'userName'\n }],\n buttons: [{\n text: 'Save',\n handler: function(){\n var fp = this.ownerCt.ownerCt,\n form = fp.getForm();\n if (form.isValid()) {\n // check if there are baseParams and if\n // hiddent items have been added already\n if (fp.baseParams && !fp.paramsAdded) {\n // add hidden items for all baseParams\n for (i in fp.baseParams) {\n fp.add({\n xtype: 'hidden',\n name: i,\n value: fp.baseParams[i]\n });\n }\n fp.doLayout();\n // set a custom flag to prevent re-adding\n fp.paramsAdded = true;\n }\n form.submit();\n }\n }\n }]\n});\n
\n\nTimeout for form actions in seconds (default is 30 seconds).
\nDefaults to: 30
A MixedCollection containing all the Ext.form.Fields in this form.
\nA MixedCollection containing all the Ext.form.Fields in this form.
\nBy default wait messages are displayed with Ext.MessageBox.wait. You can target a specific\nelement by passing it or its id or mask the form itself by passing in true.
\nThe form element or its id
\nConfiguration options
\nAdd Ext.form Components to this form's Collection. This does not result in rendering of\nthe passed Component, it just enables the form to validate Fields, and distribute values to\nFields.
\n\nYou will not usually call this function. In order to be rendered, a Field must be added\nto a Container, usually an FormPanel.\nThe FormPanel to which the field is added takes care of adding the Field to the BasicForm's\ncollection.
\n\nthis
\nAdds the specified events to the list of events which this Observable may fire.
\nEither an object with event names as properties with a value of true
\nor the first event name string if multiple event names are being passed as separate parameters.
. Event name if multiple event names are being passed as separate parameters.\nUsage:
\n\nthis.addEvents('storeloaded', 'storecleared');\n
\n\nAppends an event handler to this object.
\nThe name of the event to listen for.
\nThe method the event invokes.
\nThe scope (this
reference) in which the handler function is executed.\nIf omitted, defaults to the object which fired the event.
An object containing handler configuration.\nproperties. This may contain any of the following properties:
this
reference) in which the handler function is executed.\nIf omitted, defaults to the object which fired the event.\nCombining Options
\nUsing the options argument, it is possible to combine different types of listeners:
\n
\nA delayed, one-time listener.\n
myDataView.on('click', this.onClick, this, {\nsingle: true,\ndelay: 100\n});
\n\nAttaching multiple handlers in 1 call
\nThe method also allows for a single argument to be passed which is a config object containing properties\nwhich specify multiple handlers.\n
\n
myGridPanel.on({\n'click' : {\n fn: this.onClick,\n scope: this,\n delay: 100\n},\n'mouseover' : {\n fn: this.onMouseOver,\n scope: this\n},\n'mouseout' : {\n fn: this.onMouseOut,\n scope: this\n}\n});
\n\nOr a shorthand syntax:
\n
myGridPanel.on({\n'click' : this.onClick,\n'mouseover' : this.onMouseOver,\n'mouseout' : this.onMouseOut,\n scope: this\n});
\n\nprivate
\nCalls Ext.applyIf for all field in this form with the passed object.
\nthis
\nCalls Ext.apply for all fields in this form with the passed object.
\nthis
\nRemoves all fields from the collection that have been destroyed.
\nClears all invalid messages in this form.
\nthis
\nDestroys this object.
\ntrue if the object is bound to a form panel. If this is the case\nthe FormPanel will take care of destroying certain things, so we're just doubling up.
\nPerforms a predefined action (Ext.form.Action.Submit or\nExt.form.Action.Load) or a custom extension of Ext.form.Action\nto perform application-specific processing.
\nThe name of the predefined action type,\nor instance of Ext.form.Action to perform.
\nThe options to pass to the Ext.form.Action.\nAll of the config options listed below are supported by both the\nsubmit and load\nactions unless otherwise noted (custom actions could also accept\nother config options):
The params to pass\n(defaults to the form's baseParams, or none if not defined)
\n\nParameters are encoded as standard HTTP parameters using Ext.urlEncode.
\n\n\nthis
\nEnables events fired by this Observable to bubble up an owner hierarchy by calling\nthis.getBubbleTarget()
if present. There is no implementation in the Observable base class.
This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default\nimplementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to\naccess the required target more quickly.
\n\n\nExample:
\n\n\nExt.override(Ext.form.Field, {\n // Add functionality to Field's initComponent to enable the change event to bubble\n initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {\n this.enableBubble('change');\n }),\n\n // We know that we want Field's events to bubble directly to the FormPanel.\n getBubbleTarget : function() {\n if (!this.formPanel) {\n this.formPanel = this.findParentByType('form');\n }\n return this.formPanel;\n }\n});\n\nvar myForm = new Ext.formPanel({\n title: 'User Details',\n items: [{\n ...\n }],\n listeners: {\n change: function() {\n // Title goes red if form has been modified.\n myForm.header.setStyle('color', 'red');\n }\n }\n});\n
\n\nFind a Ext.form.Field in this form.
\nThe value to search for (specify either a id,\ndataIndex, name or hiddenName).
\nField
\nFires the specified event with the passed parameters (minus the event name).
\n\n\nAn event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget)\nby calling enableBubble.
\n\nThe name of the event to fire.
\nVariable number of parameters are passed to handlers.
\nreturns false if any of the handlers return false otherwise it returns true.
\nRetrieves the fields in the form as a set of key/value pairs, using the getValue() method.\nIf multiple fields exist with the same name they are returned as an array.
\nTrue to return only fields that are dirty.
\nThe values in the form
\nReturns the fields in this form as an object with key/value pairs as they would be submitted using a standard form submit.\nIf multiple fields exist with the same name they are returned as an array.
\n\n\nNote: The values are collected from all enabled HTML input elements within the form, not from\nthe Ext Field objects. This means that all returned values are Strings (or Arrays of Strings) and that the\nvalue can potentially be the emptyText of a field.
\n\nPass true to return the values as a string. (defaults to false, returning an Object)
\nChecks to see if this object has any listeners for a specified event
\nThe name of the event to check for
\nTrue if the event is being listened for, else false
\nReturns true if any fields in this form have changed from their original values.
\n\n\nNote that if this BasicForm was configured with trackResetOnLoad then the\nFields' original values are updated when the values are loaded by setValues\nor loadRecord.
\n\nBoolean
\nReturns true if client-side validation on the form is successful.
\nBoolean
\nShortcut to do a load action.
\nThe options to pass to the action (see doAction for details)
\nthis
\nLoads an Ext.data.Record into this form by calling setValues with the\nrecord data.\nSee also trackResetOnLoad.
\nThe record to load
\nthis
\nMark fields in this form invalid in bulk.
\nEither an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
\nthis
\nAppends an event handler to this object (shorthand for addListener.)
\nThe type of event to listen for
\nThe method the event invokes
\nThe scope (this
reference) in which the handler function is executed.\nIf omitted, defaults to the object which fired the event.
An object containing handler configuration.
\nRelays selected events from the specified Observable as if the events were fired by this.
\nThe Observable whose events this object is to relay.
\nArray of event names to relay.
\nRemoves a field from the items collection (does NOT remove its markup).
\nthis
\nRemoves an event handler.
\nThe type of event the handler was associated with.
\nThe handler to remove. This must be a reference to the function passed into the addListener call.
\nThe scope originally specified for the handler.
\nIterates through the Fields which have been added to this BasicForm,\nchecks them for an id attribute, and calls Ext.form.Field.applyToMarkup on the existing dom element with that id.
\nthis
\nResume firing events. (see suspendEvents)\nIf events were suspended using the queueSuspended parameter, then all\nevents fired during event suspension will be sent to any listeners now.
\nSet values for fields in this form in bulk.
\nEither an array in the form:
\n\n[{id:'clientName', value:'Fred. Olsen Lines'},\n {id:'portOfLoading', value:'FXT'},\n {id:'portOfDischarge', value:'OSL'} ]
\n\n\nor an object hash of the form:
\n\n{\n clientName: 'Fred. Olsen Lines',\n portOfLoading: 'FXT',\n portOfDischarge: 'OSL'\n}
\n\nthis
\nShortcut to do a submit action.
\nThe options to pass to the action (see doAction for details).
Note: this is ignored when using the standardSubmit option.
\n\n\nThe following code:
\n\n\nmyFormPanel.getForm().submit({\n clientValidation: true,\n url: 'updateConsignment.php',\n params: {\n newStatus: 'delivered'\n },\n success: function(form, action) {\n Ext.Msg.alert('Success', action.result.msg);\n },\n failure: function(form, action) {\n switch (action.failureType) {\n case Ext.form.Action.CLIENT_INVALID:\n Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');\n break;\n case Ext.form.Action.CONNECT_FAILURE:\n Ext.Msg.alert('Failure', 'Ajax communication failed');\n break;\n case Ext.form.Action.SERVER_INVALID:\n Ext.Msg.alert('Failure', action.result.msg);\n }\n }\n});\n
\n\n\nwould process the following server response for a successful submission:
\n\n{\n \"success\":true, // note this is Boolean, not string\n \"msg\":\"Consignment updated\"\n}\n
\n\n\nand the following server response for a failed submission:
\n\n{\n \"success\":false, // note this is Boolean, not string\n \"msg\":\"You do not have permission to perform this operation\"\n}\n
\n\nthis
\nSuspend the firing of all events. (see resumeEvents)
\nPass as true to queue up suspended events to be fired\nafter the resumeEvents call instead of discarding all suspended events;
\nRemoves an event handler (shorthand for removeListener.)
\nThe type of event the handler was associated with.
\nThe handler to remove. This must be a reference to the function passed into the addListener call.
\nThe scope originally specified for the handler.
\nPersists the values in this form into the passed Ext.data.Record object in a beginEdit/endEdit block.
\nThe record to edit
\nthis
\nFires when an action is completed.
\nThe Ext.form.Action that completed
\nFires when an action fails.
\nThe Ext.form.Action that failed
\nFires before any action is performed. Return false to cancel the action.
\nThe Ext.form.Action to be performed
\n