ObservableBasicForm
| Package: | CQ.Ext.form |
| Class: | BasicForm |
| Extends: | CQ.Ext.util.Observable |
| Clientlib: | cq.widgets |
Encapsulates the DOM <form> element at the heart of the FormPanel class, and provides input field management, validation, submission, and form loading services.
By default, Ext Forms are submitted through Ajax, using an instance of CQ.Ext.form.Action.Submit. To enable normal browser submission of an Ext Form, use the standardSubmit config option.
File Uploads
File uploads are not performed using Ajax submission, that is they are not performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the DOM <form> element temporarily modified to have its target set to refer to a dynamically generated, hidden <iframe> which is inserted into the document but removed after the return data has been gathered.
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 Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.
Characters which are significant to an HTML parser must be sent as HTML entities, so encode "<" as "<", "&" as "&" etc.
The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a responseText property in order to conform to the requirements of event handlers and callbacks.
Be aware that file upload packets are sent with the content type multipart/form and some server technologies (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from the packet content.
| Config Options | Defined By | |
|---|---|---|
|
api : Object (Optional) If specified load and submit actions will be handled with CQ.Ext.form.Action.DirectLoad and CQ.Ext.form.Ac...
(Optional) If specified load and submit actions will be handled with CQ.Ext.form.Action.DirectLoad and CQ.Ext.form.Action.DirectSubmit. Methods which have been imported by CQ.Ext.Direct can be specified here to load and submit forms. Such as the following:
Load actions can use |
BasicForm | |
|
baseParams : Object Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}. Parameters are encoded as standard HT...
Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}. Parameters are encoded as standard HTTP parameters using CQ.Ext.urlEncode. |
BasicForm | |
|
errorReader : DataReader An CQ.Ext.data.DataReader (e.g. CQ.Ext.data.XmlReader) to be used to read field error messages returned from 'submit'...
An CQ.Ext.data.DataReader (e.g. CQ.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. 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. The errorReader does not have to be a full-blown implementation of a DataReader. It simply needs to implement a read(xhr) function which returns an Array of Records in an object with the following structure: |
BasicForm | |
|
fileUpload : Boolean Set to true if this form is a file upload. File uploads are not performed using normal 'Ajax' techniques, that is the...
Set to true if this form is a file upload.
File uploads are not performed using normal 'Ajax' techniques, that is they are not performed using XMLHttpRequests. Instead the form is submitted in the standard manner with the DOM <form> element temporarily modified to have its target set to refer to a dynamically generated, hidden <iframe> which is inserted into the document but removed after the return data has been gathered. 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 Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body. Characters which are significant to an HTML parser must be sent as HTML entities, so encode "<" as "<", "&" as "&" etc. The response text is retrieved from the document, and a fake XMLHttpRequest object is created containing a responseText property in order to conform to the requirements of event handlers and callbacks. Be aware that file upload packets are sent with the content type multipart/form and some server technologies (notably JEE) may require some custom processing in order to retrieve parameter names and parameter values from the packet content. |
BasicForm | |
|
method : String
The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
|
BasicForm | |
|
paramOrder : Array/String A list of params to be executed server side. Defaults to undefined. Only used for the api load configuration. Specify...
A list of params to be executed server side. Defaults to undefined. Only used for the 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: |
BasicForm | |
|
paramsAsHash : Boolean Only used for the api load configuration. Send parameters as a collection of named arguments (defaults to false). Pro...
Only used for the
api load configuration. Send parameters as a collection of named arguments (defaults to false). Providing a paramOrder nullifies this configuration. |
BasicForm | |
|
reader : DataReader An CQ.Ext.data.DataReader (e.g. CQ.Ext.data.XmlReader) to be used to read data when executing 'load' actions. This is...
An CQ.Ext.data.DataReader (e.g. CQ.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.
|
BasicForm | |
|
standardSubmit : Boolean If set to true, standard HTML form submits are used instead of XHR (Ajax) style form submissions. Defaults to false. ...
If set to true, standard HTML form submits are used instead of XHR (Ajax) style form submissions. Defaults to false. Note: When using |
BasicForm | |
|
timeout : Number Timeout for form actions in seconds (defaults to CQ.REQUEST_TIMEOUT divided by 1000).
Timeout for form actions in seconds (defaults to CQ.REQUEST_TIMEOUT divided by 1000).
|
BasicForm | |
| trackResetOnLoad : Boolean | BasicForm | |
|
url : String The URL to use for form actions if one isn't supplied in the doAction options.
The URL to use for form actions if one isn't supplied in the
doAction options. |
BasicForm | |
|
waitTitle : String The default title to show for the waiting message box (defaults to 'Please Wait...')
The default title to show for the waiting message box (defaults to 'Please Wait...')
|
BasicForm | |
| Property | Defined By | |
|---|---|---|
|
items : MixedCollection
A MixedCollection containing all the CQ.Ext.form.Fields in this form.
|
BasicForm | |
|
waitMsgTarget : Mixed
By default wait messages are displayed with CQ.Ext.MessageBox.wait. You can target a specific
element by passing it ...
By default wait messages are displayed with CQ.Ext.MessageBox.wait. You can target a specific
element by passing it or its id or mask the form itself by passing in true.
|
BasicForm | |
| Method | Defined By | |
|---|---|---|
BasicForm( Mixed el, Object config )
Parameters:
|
BasicForm | |
add( Field field1, [Field field2], [Field etc] ) : BasicForm Add CQ.Ext.form Components to this form's Collection. This does not result in rendering of
the passed Component, it j...
Add CQ.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.
You will not usually call this function. In order to be rendered, a Field must be added to a Container, usually an FormPanel. The FormPanel to which the field is added takes care of adding the Field to the BasicForm's collection.
Parameters:
|
BasicForm | |
applyIfToFields( Object values ) : BasicForm Calls CQ.Ext.applyIf for all field in this form with the passed object.
Calls CQ.Ext.applyIf for all field in this form with the passed object.
Parameters:
|
BasicForm | |
applyToFields( Object values ) : BasicForm Calls CQ.Ext.apply for all fields in this form with the passed object.
Calls CQ.Ext.apply for all fields in this form with the passed object.
Parameters:
|
BasicForm | |
|
cleanDestroyed() : void Removes all fields from the collection that have been destroyed.
Removes all fields from the collection that have been destroyed.
Parameters:
|
BasicForm | |
|
clearInvalid() : BasicForm Clears all invalid messages in this form.
Clears all invalid messages in this form.
Parameters:
|
BasicForm | |
doAction( String/Object actionName, [Object options] ) : BasicForm Performs a predefined action (CQ.Ext.form.Action.Submit or
CQ.Ext.form.Action.Load) or a custom extension of CQ.Ext.f...
Performs a predefined action (CQ.Ext.form.Action.Submit or
CQ.Ext.form.Action.Load) or a custom extension of CQ.Ext.form.Action
to perform application-specific processing.
Parameters:
|
BasicForm | |
enableBubble( String/Array events ) : void Enables events fired by this Observable to bubble up an owner hierarchy by calling
this.getBubbleTarget() if present....
Enables events fired by this Observable to bubble up an owner hierarchy by calling
This is commonly used by CQ.Ext.Components to bubble events to owner Containers. See CQ.Ext.Component.getBubbleTarget. The default implementation in CQ.Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly. Example:
Parameters:
|
Observable | |
findField( String id ) : Field Find a CQ.Ext.form.Field in this form.
Find a CQ.Ext.form.Field in this form.
Parameters:
|
BasicForm | |
|
getEl() : CQ.Ext.Element Get the HTML form Element
Get the HTML form Element
Parameters:
|
BasicForm | |
getFieldValues( [Boolean dirtyOnly] ) : Object Retrieves the fields in the form as a set of key/value pairs, using the getValue() method.
If multiple fields exist w...
Retrieves the fields in the form as a set of key/value pairs, using the getValue() method.
If multiple fields exist with the same name they are returned as an array.
Parameters:
|
BasicForm | |
getValues( [Boolean asString] ) : String/Object Returns the fields in this form as an object with key/value pairs as they would be submitted using a standard form su...
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. Note: The values are collected from all enabled HTML input elements within the form, not 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.
Parameters:
|
BasicForm | |
|
isDirty() : Boolean Returns true if any fields in this form have changed from their original values.
Note that if this BasicForm was conf...
Returns true if any fields in this form have changed from their original values. Note that if this BasicForm was configured with trackResetOnLoad then the Fields' original values are updated when the values are loaded by setValues or loadRecord.
Parameters:
|
BasicForm | |
|
isValid() : Boolean Returns true if client-side validation on the form is successful.
Returns true if client-side validation on the form is successful.
Parameters:
|
BasicForm | |
load( Object options ) : BasicForm Shortcut to do a load action.
Shortcut to do a load action.
Parameters:
|
BasicForm | |
loadRecord( Record record ) : BasicForm Loads an CQ.Ext.data.Record into this form by calling setValues with the
record data.
See also trackResetOnLoad.
Loads an CQ.Ext.data.Record into this form by calling setValues with the
record data.
See also trackResetOnLoad.
Parameters:
|
BasicForm | |
markInvalid( Array/Object errors ) : BasicForm Mark fields in this form invalid in bulk.
Mark fields in this form invalid in bulk.
Parameters:
|
BasicForm | |
relayEvents( Object o, Array events ) : void Relays selected events from the specified Observable as if the events were fired by this.
Relays selected events from the specified Observable as if the events were fired by this.
Parameters:
|
Observable | |
remove( Field field ) : BasicForm Removes a field from the items collection (does NOT remove its markup).
Removes a field from the items collection (does NOT remove its markup).
Parameters:
|
BasicForm | |
|
render() : BasicForm Iterates through the Fields which have been added to this BasicForm,
checks them for an id attribute, and calls CQ.Ex...
Iterates through the Fields which have been added to this BasicForm,
checks them for an id attribute, and calls CQ.Ext.form.Field.applyToMarkup on the existing dom element with that id.
Parameters:
|
BasicForm | |
|
reset() : BasicForm Resets this form.
Resets this form.
Parameters:
|
BasicForm | |
setValues( Array/Object values ) : BasicForm Set values for fields in this form in bulk.
Set values for fields in this form in bulk.
Parameters:
|
BasicForm | |
submit( Object options ) : BasicForm Shortcut to do a submit action.
Shortcut to do a submit action.
Parameters:
|
BasicForm | |
updateRecord( Record record ) : BasicForm Persists the values in this form into the passed CQ.Ext.data.Record object in a beginEdit/endEdit block.
Persists the values in this form into the passed CQ.Ext.data.Record object in a beginEdit/endEdit block.
Parameters:
|
BasicForm | |
| Event | Defined By | |
|---|---|---|
actioncomplete : ( Form this, Action action ) Fires when an action is completed.
Fires when an action is completed.
Listeners will be called with the following arguments:
|
BasicForm | |
actionfailed : ( Form this, Action action ) Fires when an action fails.
Fires when an action fails.
Listeners will be called with the following arguments:
|
BasicForm | |
beforeaction : ( Form this, Action action ) Fires before any action is performed. Return false to cancel the action.
Fires before any action is performed. Return false to cancel the action.
Listeners will be called with the following arguments:
|
BasicForm | |