Class RapidContext.Widget.Form

Extends: RapidContext.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.

Source code: RapidContext_Widget_Form.js

Class Summary
 
Creates a new form widget.
Method Summary
 
Returns a map with all child DOM nodes containing form fields with a name attribute.
 
Returns an array with all child DOM nodes containing form fields.
 
Resets all fields in the form to their default values.
 
update(values)
Updates the fields in this form with a specified map of values.
 
Validates this form using the form validators found.
 
Resets all form validators.
 
Returns an array with all child DOM nodes containing form validator widgets.
 
Returns a map with all form field values.
Methods borrowed from class RapidContext.Widget:
addAll, addChildNode, addClass, animate, blurAll, destroy, disable, enable, getChildNodes, hasClass, hide, isDisabled, isHidden, removeAll, removeChildNode, removeClass, setAttrs, setStyle, show, toggleClass, uid
Class Detail
RapidContext.Widget.Form(attrs)
Creates a new form widget.
JavaScript:
var field = RapidContext.Widget.TextField({ name: "name", helpText: "Your Name Here" });
var attrs = { name: "name", message: "Please enter your name to proceed." };
var valid = RapidContext.Widget.FormValidator(attrs);
var exampleForm = RapidContext.Widget.Form({}, field, valid);
User Interface XML:
<Form id="exampleForm">
  <TextField name="name" helpText="Your Name Here" />
  <FormValidator name="name" message="Please enter your name to proceed." />
</Form>
Parameters:
{Object} attrs
the widget and node attributes
{Boolean} attrs.hidden Optional
the hidden widget flag, defaults to false
{Object} ... Optional
the child widgets or DOM nodes
Returns:
{Widget} the widget DOM node
Method Detail
{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 RapidContext.Widget.isFormField() function.
Returns:
{Array} the array of form field elements

{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

reset()
Resets all fields in the form to their default values.

{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

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

{Array} validators()
Returns an array with all child DOM nodes containing form validator widgets.
Returns:
{Array} the array of form validator widgets

{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. This metod is automatically called upon form reset.