Properties Methods Events Config Options Direct Link

    Observable
      BasicForm

# Class Ext.form.BasicForm

Package: | Ext.form
Defined In: | BasicForm.js
Class: | BasicForm
Extends: | Observable

Supplies the functionality to do "actions" on forms and initialize Ext.form.Field types on existing markup.
By default, Ext Forms are submitted through Ajax, using Ext.form.Action. To enable normal browser submission of an Ext Form, override the Form's onSubmit, and submit methods:

    var myForm = new Ext.form.BasicForm("form-el-id", {
            onSubmit: Ext.emptyFn,
            submit: function() {
                this.getEl().dom.submit();
            }
        });

## Config Options

Config Options | Defined By
--- | ---
| baseParams : Object Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}. | BasicForm
| errorReader : DataReader An Ext.data.DataReader (e.g. Ext.data.XmlReader) to be used to read data when reading validation errors on "submit" a... An Ext.data.DataReader (e.g. Ext.data.XmlReader) to be used to read data when reading validation errors on "submit" actions. This is completely optional as there is built-in support for processing JSON. | BasicForm
| fileUpload : Boolean Set to true if this form is a file upload. | BasicForm
| listeners : Object A config object containing one or more event handlers to be added to this object during initialization. This should b... A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. | Observable
| method : String The request method to use (GET or POST) for form actions if one isn't supplied in the action options. | BasicForm
| reader : DataReader An Ext.data.DataReader (e.g. Ext.data.XmlReader) to be used to read data when executing "load" actions. This is optio... An Ext.data.DataReader (e.g. 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. | BasicForm
| timeout : Number Timeout for form actions in seconds (default is 30 seconds). | BasicForm
| trackResetOnLoad : Boolean If set to true, form.reset() resets to the last loaded or setValues() data instead of when the form was first created. | BasicForm
| url : String The URL to use for form actions if one isn't supplied in the action options. | BasicForm

## Public Properties

Property | Defined By
--- | ---
| waitMsgTarget : Mixed By default wait messages are displayed with Ext.MessageBox.wait. You can target a specific element by passing it or i... 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. | BasicForm

## Public Methods

Method | Defined By
--- | ---

BasicForm( `Mixed el`, `Object config` )
Parameters:

- `el` : Mixed
  The form element or its id
- `config` : Object
  Configuration options

Returns:

- ``

BasicForm

add( `Field field1`, [`Field field2`], [`Field etc`] ) : BasicForm
Add Ext.form components to this form.
Add Ext.form components to this form.
Parameters:

- `field1` : Field
- `field2` : Field
  (optional)
- `etc` : Field
  (optional)

Returns:

- `BasicForm`
  this

BasicForm

addEvents( `Object object` ) : void
Used to define events on this Observable
Used to define events on this Observable
Parameters:

- `object` : Object
  The object with the events defined

Returns:

- `void`

Observable

addListener( `String eventName`, `Function handler`, [`Object scope`], [`Object options`] ) : void
Appends an event handler to this component
Appends an event handler to this component
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The method the event invokes
- `scope` : Object
  (optional) The scope in which to execute the handler function. The handler function's "this" context.
- `options` : Object
  (optional) An object containing handler configuration properties. This may contain any of the following properties:
  - scope : Object

    The scope in which to execute the handler function. The handler function's "this" context.

  - delay : Number

    The number of milliseconds to delay the invocation of the handler after the event fires.

  - single : Boolean

    True to add a handler to handle just the next firing of the event, and then remove itself.

  - buffer {Number} Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.

  Combining Options
  Using the options argument, it is possible to combine different types of listeners:
  A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)

      el.on('click', this.onClick, this, {
          single: true,
          delay: 100,
          forumId: 4
      });

  Attaching multiple handlers in 1 call
  The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers.

      foo.on({
          'click' : {
              fn: this.onClick,
              scope: this,
              delay: 100
          },
          'mouseover' : {
              fn: this.onMouseOver,
              scope: this
          },
          'mouseout' : {
              fn: this.onMouseOut,
              scope: this
          }
      });

  Or a shorthand syntax:

      foo.on({
          'click' : this.onClick,
          'mouseover' : this.onMouseOver,
          'mouseout' : this.onMouseOut,
           scope: this
      });

Returns:

- `void`

Observable

applyIfToFields( `Object values` ) : BasicForm
Calls Ext.applyIf for all field in this form with the passed object.
Calls Ext.applyIf for all field in this form with the passed object.
Parameters:

- `values` : Object

Returns:

- `BasicForm`
  this

BasicForm

applyToFields( `Object values` ) : BasicForm
Calls Ext.apply for all fields in this form with the passed object.
Calls Ext.apply for all fields in this form with the passed object.
Parameters:

- `values` : Object

Returns:

- `BasicForm`
  this

BasicForm

clearInvalid() : BasicForm
Clears all invalid messages in this form.
Clears all invalid messages in this form.
Parameters:

- None.

Returns:

- `BasicForm`
  this

BasicForm

doAction( `String/Object actionName`, [`Object options`] ) : BasicForm
Performs a predefined action (Ext.form.Action.Submit or Ext.form.Action.Load) or a custom extension of Ext.form.Actio...
Performs a predefined action (Ext.form.Action.Submit or Ext.form.Action.Load) or a custom extension of Ext.form.Action to perform application-specific processing.
Parameters:

- `actionName` : String/Object
  The name of the predefined action type, or instance of Ext.form.Action to perform.
- `options` : Object
  (optional) The options to pass to the Ext.form.Action. All of the config options listed below are supported by both the submit and load actions unless otherwise noted (custom actions could also accept other config options):
  - url : String

    The url for the action (defaults to the form's url.)

  - method : String

    The form method to use (defaults to the form's method, or POST if not defined)

  - params : String/Object

    The params to pass (defaults to the form's baseParams, or none if not defined)

  - success : Function

    The callback that will be invoked after a successful response. Note that this is HTTP success (the transaction was sent and received correctly), but the resulting response data can still contain data errors. The function is passed the following parameters:

    - `form` : Ext.form.BasicForm
      The form that requested the action
    - `action` : Ext.form.Action
      The Action class. The result property of this object may be examined to perform custom postprocessing.
  - failure : Function

    The callback that will be invoked after a failed transaction attempt. Note that this is HTTP failure, which means a non-successful HTTP code was returned from the server. The function is passed the following parameters:

    - `form` : Ext.form.BasicForm
      The form that requested the action
    - `action` : Ext.form.Action
      The Action class. If an Ajax error ocurred, the failure type will be in failureType. The result property of this object may be examined to perform custom postprocessing.
  - scope : Object

    The scope in which to call the callback functions (The `this` reference for the callback functions).

  - clientValidation : Boolean

    Submit Action only. Determines whether a Form's fields are validated in a final call to isValid prior to submission. Pass `false` in the to prevent this. If not defined, pre-submission field validation is performed.

Returns:

- `BasicForm`
  this

BasicForm

findField( `String id` ) : Field
Find a Ext.form.Field in this form by id, dataIndex, name or hiddenName.
Find a Ext.form.Field in this form by id, dataIndex, name or hiddenName.
Parameters:

- `id` : String
  The value to search for

Returns:

- `Field`

BasicForm

fireEvent( `String eventName`, `Object... args` ) : Boolean
Fires the specified event with the passed parameters (minus the event name).
Fires the specified event with the passed parameters (minus the event name).
Parameters:

- `eventName` : String
- `args` : Object...
  Variable number of parameters are passed to handlers

Returns:

- `Boolean`
  returns false if any of the handlers return false otherwise it returns true

Observable

getEl() : Ext.Element
Get the HTML form Element
Get the HTML form Element
Parameters:

- None.

Returns:

- `Ext.Element`

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.
Parameters:

- `asString` : Boolean
  (optional) false to return the the values as an object (defaults to returning as a string)

Returns:

- `String/Object`

BasicForm

hasListener( `String eventName` ) : Boolean
Checks to see if this object has any listeners for a specified event
Checks to see if this object has any listeners for a specified event
Parameters:

- `eventName` : String
  The name of the event to check for

Returns:

- `Boolean`
  True if the event is being listened for, else false

Observable

isDirty() : Boolean
Returns true if any fields in this form have changed since their original load.
Returns true if any fields in this form have changed since their original load.
Parameters:

- None.

Returns:

- `Boolean`

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:

- None.

Returns:

- `Boolean`

BasicForm

load( `Object options` ) : BasicForm
Shortcut to do a load action.
Shortcut to do a load action.
Parameters:

- `options` : Object
  The options to pass to the action (see doAction for details)

Returns:

- `BasicForm`
  this

BasicForm

loadRecord( `Record record` ) : BasicForm
Loads an Ext.data.Record into this form.
Loads an Ext.data.Record into this form.
Parameters:

- `record` : Record
  The record to load

Returns:

- `BasicForm`
  this

BasicForm

markInvalid( `Array/Object errors` ) : BasicForm
Mark fields in this form invalid in bulk.
Mark fields in this form invalid in bulk.
Parameters:

- `errors` : Array/Object
  Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}

Returns:

- `BasicForm`
  this

BasicForm

on( `String eventName`, `Function handler`, [`Object scope`], [`Object options`] ) : void
Appends an event handler to this element (shorthand for addListener)
Appends an event handler to this element (shorthand for addListener)
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The method the event invokes
- `scope` : Object
  (optional) The scope in which to execute the handler function. The handler function's "this" context.
- `options` : Object
  (optional)

Returns:

- `void`

Observable

purgeListeners() : void
Removes all listeners for this object
Removes all listeners for this object
Parameters:

- None.

Returns:

- `void`

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:

- `field` : Field

Returns:

- `BasicForm`
  this

BasicForm

removeListener( `String eventName`, `Function handler`, [`Object scope`] ) : void
Removes a listener
Removes a listener
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The handler to remove
- `scope` : Object
  (optional) The scope (this object) for the handler

Returns:

- `void`

Observable

render() : BasicForm
Looks at the fields in this form, checks them for an id attribute, and calls applyTo on the existing dom element with...
Looks at the fields in this form, checks them for an id attribute, and calls applyTo on the existing dom element with that id.
Parameters:

- None.

Returns:

- `BasicForm`
  this

BasicForm

reset() : BasicForm
Resets this form.
Resets this form.
Parameters:

- None.

Returns:

- `BasicForm`
  this

BasicForm

resumeEvents() : void
Resume firing events. (see suspendEvents)
Resume firing events. (see suspendEvents)
Parameters:

- None.

Returns:

- `void`

Observable

setValues( `Array/Object values` ) : BasicForm
Set values for fields in this form in bulk.
Set values for fields in this form in bulk.
Parameters:

- `values` : Array/Object
  Either an array in the form:
  `

      [{id:'clientName', value:'Fred. Olsen Lines'},
       {id:'portOfLoading', value:'FXT'},
       {id:'portOfDischarge', value:'OSL'} ]

  `
  or an object hash of the form:
  `

      {
          clientName: 'Fred. Olsen Lines',
          portOfLoading: 'FXT',
          portOfDischarge: 'OSL'
      }

  `

Returns:

- `BasicForm`
  this

BasicForm

submit( `Object options` ) : BasicForm
Shortcut to do a submit action.
Shortcut to do a submit action.
Parameters:

- `options` : Object
  The options to pass to the action (see doAction for details)

Returns:

- `BasicForm`
  this

BasicForm

suspendEvents() : void
Suspend the firing of all events. (see resumeEvents)
Suspend the firing of all events. (see resumeEvents)
Parameters:

- None.

Returns:

- `void`

Observable

un( `String eventName`, `Function handler`, [`Object scope`] ) : void
Removes a listener (shorthand for removeListener)
Removes a listener (shorthand for removeListener)
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The handler to remove
- `scope` : Object
  (optional) The scope (this object) for the handler

Returns:

- `void`

Observable

updateRecord( `Record record` ) : BasicForm
Persists the values in this form into the passed Ext.data.Record object in a beginEdit/endEdit block.
Persists the values in this form into the passed Ext.data.Record object in a beginEdit/endEdit block.
Parameters:

- `record` : Record
  The record to edit

Returns:

- `BasicForm`
  this

BasicForm

## Public Events

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:

- `this` : Form
- `action` : Action
  The Ext.form.Action that completed

BasicForm

actionfailed : ( `Form this`, `Action action` )
Fires when an action fails.
Fires when an action fails.
Listeners will be called with the following arguments:

- `this` : Form
- `action` : Action
  The Ext.form.Action that failed

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:

- `this` : Form
- `action` : Action
  The Ext.form.Action to be performed

BasicForm