Class MochiKit.Widget.Form
Extends
MochiKit.Widget.
The form widget class. Provides a grouping for form fields,
using the <form> HTML element. The form widget supports
form reset, validation and data retrieval.
Defined in: Widget.js.
Constructor Attributes | Constructor Name and Description |
---|---|
MochiKit.Widget.Form(attrs)
Creates a new form widget.
|
- Fields borrowed from class MochiKit.Widget:
- _id, Classes
Method Attributes | Method Name and Description |
---|---|
_handleSubmit(evt)
Handles the form submit signal.
|
|
fieldMap()
Returns a map with all child DOM nodes containing form fields with
a name attribute.
|
|
fields()
Returns an array with all child DOM nodes containing form fields.
|
|
reset()
Resets all fields in the form to their default values.
|
|
update(values)
Updates the fields in this form with a specified map of values.
|
|
validate()
Validates this form using the form validators found.
|
|
Resets all form validators.
|
|
Returns an array with all child DOM nodes containing form
validator widgets.
|
|
valueMap()
Returns a map with all form field values.
|
- Methods borrowed from class MochiKit.Widget:
- _animQueueId, _createWidgetTreeElem, _eventHandler, _widgetMixin, addAll, addChildNode, addClass, animate, blurAll, createWidget, createWidgetTree, destroy, destroyWidget, emitSignal, getChildNodes, hasClass, hide, isFormField, isHidden, isWidget, removeAll, removeChildNode, removeClass, setAttrs, setStyle, show, toggleClass
Class Detail
MochiKit.Widget.Form(attrs)
Creates a new form widget.
- Parameters:
- {Object} attrs
- the widget and node attributes
- {Object} ... Optional
- the child widgets or DOM nodes
- Returns:
- {Widget} the widget DOM node
Method Detail
_handleSubmit(evt)
Handles the form submit signal.
- Parameters:
- {Event} evt
- the MochiKit.Signal.Event object
{Object}
fieldMap()
Returns a map with all child DOM nodes containing form fields with
a name attribute. If multiple fields have the same name, the
returned map will contain an array with all matching fields.
- Returns:
- {Object} the map of form field elements
{Array}
fields()
Returns an array with all child DOM nodes containing form fields.
The child nodes will be returned based on the results of the
MochiKit.Widget.isFormField() function.
- Returns:
- {Array} the array of form field elements
reset()
Resets all fields in the form to their default values.
update(values)
Updates the fields in this form with a specified map of values.
If multiple fields have the same name, the value will be set to
all of them.
- Parameters:
- {Object} values
- the map of form field values
{Boolean/MochiKit.Async.Deferred}
validate()
Validates this form using the form validators found.
- Returns:
- {Boolean/MochiKit.Async.Deferred} true if the form validated successfully, false if the validation failed, or a MochiKit.Async.Deferred instance if the validation was deferred
validateReset()
Resets all form validators.
{Array}
validators()
Returns an array with all child DOM nodes containing form
validator widgets.
- Returns:
- {Array} the array of form validator widgets
{Object}
valueMap()
Returns a map with all form field values. If multiple fields have
the same name, the value will be set to an array of all values.
Any unchecked checkbox or radiobutton will be also be ignored.
- Returns:
- {Object} the map of form field values