constructor
flagrate.createForm
flagrate.createForm(option) → flagrate.Form
new flagrate.Form
option
(Object
) – configuration.
Create and initialize the Form.
option
fields
(Array; default[]
): of field object.id
(String):id
attribute of container.className
(String):class
attribute of container.attribute
(Object): additional attribute of container.style
(Object): style of container. (using flagrate.Element.setStyle)nolabel
(Boolean; defaultfalse
): hide labels.vertical
(Boolean; defaultfalse
): vertical label style.
field
key
(String):pointer
(String|null):label
(String; default""
):icon
(String):text
(String):html
(String):element
(Element):input
(Object): see inputdepends
(Array): of dependid
(String):id
attribute of container.className
(String):class
attribute of container.attribute
(Object): additional attribute of container.style
(Object): style of container. (using flagrate.Element.setStyle)
input
type
(String|Object; required): inputtype String or Objectval
(any): default value(s) of this input.isRequired
(Boolean; defaultfalse
):min
(Number): (simple validator)max
(Number): (simple validator)minLength
(Number): (simple validator)maxLength
(Number): (simple validator)validators
(Array): of inputValidator String or Object or Function.toString
(Boolean; defaultfalse
): if NOT String, use #toString() before resulting.trim
(Boolean; defaultfalse
): if String, use String#trim() before resulting.toNumber
(Boolean; defaultfalse
): if NOT Number, tries to convert to Number.transform
(Function): alternate result transform/converting function. (only sync)id
(String):id
attribute of input element.
depend
key
(String): unique key for identifying fields. if looking result, must change to use the pointer.pointer
(String):val
(any):op
(String):===
,!==
,>=
,<=
,>
,<
,in
tester
(Function): alternate testing function. this disables normal testing. (only sync)
inputType
if specified a String, will use flagrate.Form.inputType[(specified)].
inputValidator
if specified a String, will use flagrate.Form.inputValidator[(specified)].
// Example: custom validator
validators: [
// using regex:
{
regexp: /^[a-z0-9]+(-[a-z0-9]+)*(\.([a-z0-9]+(-[a-z0-9]+)*))*$/i,
error: 'Please enter a valid hostname string.'
},
// using async function:
function (input, done) {
someAsyncFunction(input, function (err, result) {
if (err) {
done('error', 'This hostname is already in use. (' + err + ')');
} else {
done('success');
}
});
},
// using sync function:
function (input, done) {
var err = someSyncFunction(input);
if (err) {
done('error', 'This hostname is prohibited. (' + err + ')');
} else {
done('success');
}
}
]
see flagrate.Form.inputValidator to read more documents.