Class: Form

Form

This class is for managing HTML form control.


new Form(domEl, options, view, connector, errorCallback)

Parameters:
Name Type Description
domEl Object

Field container.

options Object

Field options.

view Object | String

Field view.

connector Alpaca.Connector

Field connector.

errorCallback function

Error callback.

Source:

Methods


ajaxSubmit()

Fires the submit in the background and hands back the jQuery promise.

An optional config can be passed in to control the underlying jQuery ajax XHR.

Source:
Returns:
Type
*

clear(stopUpdateTrigger)

Clears the form and resets values of its fields.

Parameters:
Name Type Description
stopUpdateTrigger

If false, triggers the update event of this event.

Source:

destroy(Boolean)

Purge any event listeners and remove the form from the DOM.

Parameters:
Name Type Argument Description
Boolean <optional>

skipParent when true, the form cleans up without traversing through parent child controls

Source:

disable()

Disables this form.

Source:

enable()

Enables this form.

Source:

fireCallback(id, arg1, arg2, arg3, arg4, arg5)

Fires a view callback for the current form.

Parameters:
Name Type Description
id
arg1
arg2
arg3
arg4
arg5
Source:

focus()

Focuses on this form.

If a callback is provided, the callback receives the focused control.

Source:

getFormEl()

Retrieves the form element.

Source:
Returns:

The rendered DOM element.

Type
Object

getId()

Returns the id of the form.

Source:
Returns:

Form id

Type
String

getParent()

Returns this form's parent.

Source:
Returns:

Form parent.

Type
Object

getType()

Returns form type.

Source:
Returns:

Form type.

Type
String

getValue()

Returns the value of the JSON rendered by this form.

Source:
Returns:

Value of the JSON rendered by this form.

Type
Any

hide()

Hides the form.

Source:

initEvents()

Initializes events handling (Form Submission) for this form.

Source:

isEmpty()

Checks if form is empty.

Source:
Returns:

True if the form is empty, false otherwise.

Type
Boolean

isFormValid()

Determines whether the top control is entirely valid.

Source:
Returns:
Type
*

onSubmit(e, form)

Handles form submit events.

Parameters:
Name Type Description
e Object

Submit event.

form Object

the form

Source:

processRender(parentEl, callback)

Responsible for fetching any templates needed so as to render the
current mode for this field.

Once completed, the onSuccess method is called.

Parameters:
Name Type Description
parentEl Object

Field container.

callback function
Source:

refreshValidationState(children)

Displays validation information of all fields of this form.

Parameters:
Name Type Description
children Boolean

whether to render validation state for child fields

Source:
Returns:

Form validation state.

Type
Object

registerSubmitHandler(func)

Registers a custom submit handler.

Parameters:
Name Type Description
func Object

Submit handler to be registered.

Source:

render(callback)

Renders this form into the container.

Parameters:
Name Type Description
callback function
Source:

setValue(value)

Sets the value of the JSON to be rendered by this form.

Parameters:
Name Type Description
value Any

Value to be set.

Source:

show()

Shows the form.

Source:

submit()

Performs a regular old submit.

Source: