|
NextDB.net | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Object | +--nextdb.html.Form
The form builder library offers three distinct database operations: inserts,
updates and queries. The library also offers a variety of simple convenience
features including automatic form validation or custom regex preferences for
form validation, layout control, date pickers, file uploaders, custom default
values, dropdown lists, captcha protection, ordering, and callback function
registries for responses. This is a good tutorial on this api:
http://nextdb.net/examples/forms.html
nextdb.html.Form is an abstract super class not meant for instantiation.
Defined in api.docs.js
See:
| Field Summary | |
<static> Object |
BOX_LAYOUT
|
<static> Object |
HORIZONTAL_LAYOUT
|
<static> Object |
VERTICAL_LAYOUT
|
| Constructor Summary | |
nextdb.html.Form()
|
|
| Method Summary | |
Object
|
afterRenderCallback(<Function> callback)
callback function executed immediately after form is added to DOM. This is useful if you want to perform custom modifications to the form's DOM structure. |
Object
|
cancelCallback(<Function> callback)
callback function executed when the cancel button is clicked. |
Object
|
columnAliases(<Object> aliases)
by default the form fields will be labeled with the column name minus any underscores, so a column 'user_comments' will appear on the form as 'user comments' but with aliases your can override that naming convention by supplying a different label { "user_comments" : "Any comments?" }
|
Object
|
confirmFields(<Array> confirm)
duplicates the given fields so the user has to enter the same thing twice to ensure spelling. |
Object
|
defaultValues(<Object> defaultValues)
optionally pre-populate the form with default values, for example: {first_name:"John",last_name:"Doe"} |
Object
|
destroy()
remove form from div and tear down the form. |
Object
|
expandFields(<Array> expand)
optionally makes given text fields expandable textareas for multi-line input from the user, generally used for messages, comments, blog posts etc. |
Object
|
fail()
fail a particular submit, use this with the interceptor |
Object
|
interceptor(<Function> interceptor)
register request interceptor that will be passed the parameter map of column/values just before being sent to server, for instance
formInstance.interceptor(function(p){
// set timestamp to now
p.timestamp="now";
// get some other parameter
alert(p.name);
});
|
Object
|
layout(<int> layout)
define the layout of the form, either box (default) horizontal or vertical. |
Object
|
message(<String> msg,<String> color)
report custom message to form user (this appears above the form). |
Object
|
obscureFields(<Array> obscure)
converts given fields to password field e.g. |
Object
|
omitFields(<Array> omit)
optionally remove certain fields from the form, these fields will not be passed to the server, so any default column values on the server will be honored. |
Object
|
options(<Object> options)
optionally define drop down list options to contrain the input from the user for certain fields, for example:
{ sex : {M : "Male", F : "Female", O : "Other"},
state : {CA : "California", NY : "New York"} }
|
Object
|
orderFields(<Array> order)
optionally order fields in the form, otherwise the field ordering will default to the natural column order in the database, this will also omit the fields not represented in the array which is a nice short cut way to omit and order all in one call. |
Object
|
setMessageId(<String> id)
allows you to set the element/div id for the error/info message field. |
Object
|
timeoutMessage(<String> timeoutMessage)
Set the timeout message for the form building |
Object
|
validation(validation)
by default all of the form fields are required, you can override the default by specifying validation rules of your own. We offer some standard built in rules, for example:
{COLUMN_NAME:nextdb.validate.EMAIL,
COLUMN_NAME:nextdb.validate.STRONG_PASSWORD,
COLUMN_NAME:email:nextdb.validate.OPTIONAL}
or you can write your own rule in the form of a regular expressions, for example:
{COLUMN_NAME:/REGEX/}
|
Object
|
whileLoading(<String> whileLoading)
set the HTML to render into the div while the form builder builds the form depending on the network latency, you might not even see this. |
| Field Detail |
<static> Object BOX_LAYOUT
<static> Object HORIZONTAL_LAYOUT
<static> Object VERTICAL_LAYOUT
| Constructor Detail |
nextdb.html.Form()
| Method Detail |
Object afterRenderCallback(<Function> callback)
callback - -required callback function executed
Object cancelCallback(<Function> callback)
callback - -required callback function executed when the cancel button is clicked.
Object columnAliases(<Object> aliases)
{ "user_comments" : "Any comments?" }
aliases - -required aliases
Object confirmFields(<Array> confirm)
confirm - -required array of columns names.
Object defaultValues(<Object> defaultValues)
defaultValues - - column:values -required object of column-name:default-value.
Object destroy()
Object expandFields(<Array> expand)
expand - -required array of columns names.
Object fail()
Object interceptor(<Function> interceptor)
formInstance.interceptor(function(p){
// set timestamp to now
p.timestamp="now";
// get some other parameter
alert(p.name);
});
of the "INSERT","UPDATE","QUERY" just before execution.
interceptor - -required function interceptor
Object layout(<int> layout)
layout - constant
Object message(<String> msg,<String> color)
msg - -required custom message at the top of the form
color - -optional
Object obscureFields(<Array> obscure)
obscure - -required array of columns names.
Object omitFields(<Array> omit)
omit - -required array of columns names.
Object options(<Object> options)
{ sex : {M : "Male", F : "Female", O : "Other"},
state : {CA : "California", NY : "New York"} }
options - -required column:{opt1:"1",opt2:"2"}
Object orderFields(<Array> order)
order - -required array of columns names.
Object setMessageId(<String> id)
id - -required assigns an id to the error message field for custom messages.
Object timeoutMessage(<String> timeoutMessage)
timeoutMessage - html string to put in the div if request for form times out.
Object validation(validation)
{COLUMN_NAME:nextdb.validate.EMAIL,
COLUMN_NAME:nextdb.validate.STRONG_PASSWORD,
COLUMN_NAME:email:nextdb.validate.OPTIONAL}
or you can write your own rule in the form of a regular expressions, for example:
{COLUMN_NAME:/REGEX/}
column - :values -required object of column-name:default-value.
Object whileLoading(<String> whileLoading)
whileLoading - html string to put in the div while the form loads
|
NextDB.net | ||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||