Class ONEGEEK.forms.Form


class ONEGEEK.forms.Form
The form validator object finds any forms on the page and attaches validation events to the inputs based on class names of the 's. If the element is a required item a * is automatically placed beside the form item and the validation script will ensure it is filled out
Defined in ONEGEEK.forms

Variable Summary
protected Boolean custom
Is this a custom configuration form?
private ONEGEEK.form.AbstractTextField[] fields
The set of ONEGEEK.form.AbstractTextField fields.
private DOMElement form
The DOM Form Element
protected String lang
The current language for the form.
protected Object options
Constants: Override in a ONEGEEK.forms.GValidator.options key/value map to suit environment
private Object propOptions
Options that can be overridden by plugins/translations

Function Summary
private Object _readOptionsRecursive (Object opts1, Object opts2)
Merges two option object key/value pairs, into one object property map.
public void applyFocus()
Apply the focus to the first form and first field (input) of the page.
public void doForm()
Add validation to the form.
public void doFormField (DOMElement input)
Apply the validator objects to a field
private DOMElement getFieldByName (Object name)
Get a field by it's name
public DOMElement getForm()
Get the DOM form.
Handle's the form level errors.
public void readOptions (Object options)
Read in custom options.
public void reset()
Reset each form field validator.
public void setOptions()
Read in any general/specific config options from the ONEGEEK.forms.GValidator.options variable.
public Boolean validate()
This function is used to validate the form

Variable Details

variable protected Boolean custom

Is this a custom configuration form?

variable private ONEGEEK.form.AbstractTextField[] fields

The set of ONEGEEK.form.AbstractTextField fields.

variable private DOMElement form

The DOM Form Element

variable protected String lang

The current language for the form.

variable protected Object options

Constants: Override in a ONEGEEK.forms.GValidator.options key/value map to suit environment

variable private Object propOptions

Options that can be overridden by plugins/translations

Function Details

function _readOptionsRecursive

private Object _readOptionsRecursive(Object opts1, Object opts2)
Merges two option object key/value pairs, into one object property map.
Parameters:
opts1 The initial options
opts2 The custom override options
Returns:
The merged options

function applyFocus

public void applyFocus()
Apply the focus to the first form and first field (input) of the page.
Returns:
void

function doForm

public void doForm()
Add validation to the form. Read the form XHTML object into an Chaos.forms.validation.Form Object and add the validation and context functions to the inputs.
Returns:
void

function doFormField

public void doFormField(DOMElement input)
Apply the validator objects to a field
Parameters:
input The form input/field to add validation to
Returns:
void

function getFieldByName

private DOMElement getFieldByName(Object name)
Get a field by it's name
Parameters:
name The name attribute of the element
Returns:
The DOM Element field if found, otherwise null

function getForm

public DOMElement getForm()
Get the DOM form.
Returns:
The DOM Form Element

function handleErrors

public Boolean handleErrors(ONEGEEK.forms.AbstractFormField[] The)
Handle's the form level errors.
Parameters:
The error fields
Returns:
false in all cases except if there is a function handler specified (as a custom option), in which case void

function readOptions

public void readOptions(Object options)
Read in custom options. Read in the options given recursively, only letting in allowable properties, and merging with existing properties.
Parameters:
options The custom override options
Returns:
void

function reset

public void reset()
Reset each form field validator.
Returns:
void

function setOptions

public void setOptions()
Read in any general/specific config options from the ONEGEEK.forms.GValidator.options variable.
Returns:
void

function validate

public Boolean validate()
This function is used to validate the form
Returns:
true if form is valid, false otherwise