Library: quickforms
Overview
EXPERIMENTAL: Library for easy forms. This library is
incomplete and skeletal. Feel free to play around with it, but we may or may
not improve it in future versions of the AppJet libraries.
To display a QuickForm, first create one, then add the fields in order, then print the QuickForm. QuickForms take care of basic formatting like labeling input fields.
source: quickforms.js
Constructors
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? | an optional dictionary of options |
methods
- addHeading(id, text)
- addInputText(id, opts)
- addInputTextArea(id, opts)
- addInputFile(id, opts)
- addInputHidden(id, val)
- addSubmit(id, text)
- validate()
- getInput()
- toHTML()
Creates a QuickButton, a self-contained button that when pressed
submits a form that contains a bunch of parameter/value pairs.
Supported options (all optional):
- method: "get" or "post" (defaults to "post")
- action: path to submit to, defaults to current path
parameters
| string | label | a label for the button |
| object | opts | a dictionary of options |
| object | inputs | a dictionary of parameter/value mappings to submit |
methods
- toHTML()
Functions
Adds a heading in bold type that introduces a section of the form.
parameters
| string | id? | (optional) unique id string, used for CSS rules |
| string | text | the text of the heading |
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? | an optional dictionary of options |
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? | an optional dictionary of options |
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? | an optional dictionary of options |
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 |
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 |
QuickForm.validate()
Does basic checking to determine whether the current request is a valid
submission of this form.
returns
| boolean |
QuickForm.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 |
QuickForm.toHTML()
Converts this QuickForm to HTML mark-up. This is called for you
when you print a QuickForm.
returns
| string | html-formatted string. |
QuickButton.toHTML()
Converts this QuickButton to HTML mark-up. This is called for you
when you print a QuickButton.
returns
| string | html-formatted string. |