import FormElement from 'elementify/lib/elements/formelement.js'
FormElement
Extends:
A FormElement instance node may contains only <form>
Element.
Its main purpose is to provide an easy way to validate a whole form and prepare data for submission
Test:
TODO:
- - Add support for binary data
Constructor Summary
Private Constructor | ||
private |
constructor(node: Element, options: KeyValueObject): FormElement The form constructor |
version 1.0.0 since 1.0.0 |
Member Summary
Public Members | ||
public get |
Form data as an ObjectArray object |
version 1.0.0 since 1.0.0 |
public set |
datas: keyValueObject | ObjectArray Import data into form fields from a KeyValueObject or an ObjectArray object |
version 1.0.0 since 1.0.0 |
public get |
Dirty state of the form. |
version 1.0.0 since 1.0.0 |
public get |
Fetch validation errors |
version 1.0.0 since 1.0.0 |
public get |
Returns a Collection of all fields. |
version 1.0.0 since 1.0.0 |
public get |
Form data as a FormData object |
version 1.0.0 since 1.0.0 |
public get |
Data of the form serialized in urlEncode standard. |
version 1.0.0 since 1.0.0 |
public get |
Data of the form returned as a JSON string |
version 1.0.0 since 1.0.0 |
public set |
Import data into form fields from JSON |
version 1.0.0 since 1.0.0 |
public get |
Data of the form serialized in urlEncode standard. |
version 1.0.0 since 1.0.0 |
Private Members | ||
private |
Errors after validation |
since 1.0.0 |
Method Summary
Public Methods | ||
public |
field(f: string): InputElement Returns a field by its name |
version 1.0.0 since 1.0.0 |
public |
Validate the form by validating each field rule. |
version 1.0.0 since 1.0.0 |
Private Constructors
private constructor(node: Element, options: KeyValueObject): FormElement version 1.0.0 since 1.0.0 source
The form constructor
Params:
Name | Type | Attribute | Description |
node | Element | Form Element |
|
options | KeyValueObject |
|
Test:
Public Members
public set datas: keyValueObject | ObjectArray version 1.0.0 since 1.0.0 source
Import data into form fields from a KeyValueObject or an ObjectArray object
public get dirty: boolean version 1.0.0 since 1.0.0 source
Dirty state of the form. Set by fetching all dirty properties of the form's fields.
Test:
public get fields: Collection version 1.0.0 since 1.0.0 source
Returns a Collection of all fields. The collection is dynamic and regenerated by querying. To ignore an input Element, just add class 'form-ignore' to it.
public get formUrlEncode: string version 1.0.0 since 1.0.0 source
Data of the form serialized in urlEncode standard. This string is suitable for a form-url-encoded data submission
public set json: string version 1.0.0 since 1.0.0 source
Import data into form fields from JSON
Throw:
public get urlEncode: string version 1.0.0 since 1.0.0 source
Data of the form serialized in urlEncode standard. This string is suitable for a query part or an URI.
Private Members
Public Methods
public field(f: string): InputElement version 1.0.0 since 1.0.0 source
Returns a field by its name
Params:
Name | Type | Attribute | Description |
f | string | Field name |