Class QuickForm

Library for easy forms.
Defined in: quickforms.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
QuickForm(opts)

Creates a new, empty QuickForm.

Method Summary
Method Attributes Method Name and Description
 
addHeading(id, text)
Adds a heading in bold type that introduces a section of the form.
 
addInputFile(id, opts)

Creates a control that allows the user to select a file for upload.

 
addInputHidden(id, val)
Adds a hidden field to the form which does not affect display, but causes an additional parameter to be submitted with the form.
 
addInputText(id, opts)

Creates a one-line text box for entering a small amount of text.

 
addInputTextArea(id, opts)

Creates a rectangular, multi-line box for entering text.

 
addSelect(id, base, keys, opts)
Creates a drop-down menu to the form that allows a user to select from several options.
 
addSubmit(id, text)
Adds a submit button to this form.
 
Assuming that the current request is a form submission of this QuickForm, assembles an object with a property for each form field.
 
Converts this QuickForm to HTML mark-up.
 
Does basic checking to determine whether the current request is a valid submission of this form.
Class Detail
QuickForm(opts)

Creates a new, empty QuickForm.

Supported options (all optional):

  • method: "get" or "post" (defaults to "post")
  • action: path to submit to, defaults to current path
  • enctype: used to change the method of data encoding
Parameters:
{object} opts Optional
an optional dictionary of options
Method Detail
addHeading(id, text)
Adds a heading in bold type that introduces a section of the form.
Parameters:
{string} id Optional
(optional) unique id string, used for CSS rules
{string} text
the text of the heading

addInputFile(id, opts)

Creates a control that allows the user to select a file for upload. This feature is particularly experimental.

Supported options (all optional):

  • label: text to label the control with, defaults to id
Parameters:
{string} id
a unique id string, used as a parameter name for this control
{object} opts Optional
an optional dictionary of options

addInputHidden(id, val)
Adds a hidden field to the form which does not affect display, but causes an additional parameter to be submitted with the form.
Parameters:
{string} id
a unique id string, used as a parameter name for this field
{string} val
the value of this parameter

addInputText(id, opts)

Creates a one-line text box for entering a small amount of text.

Supported options (all optional):

  • label: text to label the field with, defaults to id
  • beforeText: text to put immediately before the input field
  • afterText: text to put immediately after the input field
  • value: initial text for the field
  • size: width of the field in characters
  • disabled: set to "disabled" to disable the field
Parameters:
{string} id
a unique id string, used as a parameter name for this field
{object} opts Optional
an optional dictionary of options

addInputTextArea(id, opts)

Creates a rectangular, multi-line box for entering text.

Supported options (all optional):

  • label: text to label the box with, defaults to id
  • rows: how many lines high to make the box
  • cols: how many characters wide to make the box
  • value: initial text for the text area
Parameters:
{string} id
a unique id string, used as a parameter name for this field
{object} opts Optional
an optional dictionary of options

addSelect(id, base, keys, opts)
Creates a drop-down menu to the form that allows a user to select from several options.
Parameters:
{string} id
a unique id string, used as a parameter name for this field
{iterable} base
an object that supports the forEach method, and whose elements contain the properties for the option elements.
{object} keys
a dictionary with properties "value", "content", and "selected", that specify the property of base's objects that should be used as the "value", menu text, and whether that menu item is selected, respecitvely.
{object} opts Optional
an optional dictionary of options.

addSubmit(id, text)
Adds a submit button to this form.
Parameters:
{string} id
a unique id string, used as a parameter name for this field
{string} text
the text on the button, and also the value of the parameter

{object} getInput()
Assuming that the current request is a form submission of this QuickForm, assembles an object with a property for each form field.
Returns:
{object}

{string} toHTML()
Converts this QuickForm to HTML mark-up. This is called for you when you print a QuickForm.
Returns:
{string} html-formatted string.

{boolean} validate()
Does basic checking to determine whether the current request is a valid submission of this form.
Returns:
{boolean}

©2011 by JGate on AppJet
Documentation generated by JsDoc Toolkit 2.1.0 on Thu Jan 06 2011 10:36:33 GMT+0100 (MEZ)