Webform
Extends:
Direct Subclass:
Renders a Form.io form within the webpage.
Constructor Summary
| Public Constructor | ||
| public |
constructor(options: Object) Creates a new Form instance. |
|
Member Summary
| Public Members | ||
| public |
alert: HTMLElement The alert HTML element |
|
| public |
component: * |
|
| public get |
|
|
| public |
components: *[] |
|
| public |
currentForm: * |
|
| public |
customErrors: *[] |
|
| public |
|
|
| public |
editing: * |
|
| public |
element: * |
|
| public |
|
|
| public get |
Gets the form object. |
|
| public set |
Sets the form value. |
|
| public |
Promise that executes when the form is ready and rendered. |
|
| public |
Called when this form could not load and is rejected. |
|
| public |
Called when the formReady state of this form has been resolved. |
|
| public |
The Formio instance for this form. |
|
| public |
|
|
| public set |
Sets the language for this form. |
|
| public |
loader: HTMLElement The loader HTML element. |
|
| public get |
Returns if this form is loading. |
|
| public set |
Set the loading state for this form, and also show the loader spinner. |
|
| public |
|
|
| public set |
|
|
| public get |
nosubmit: * |
|
| public |
Promise that is triggered when the submission is done loading. |
|
| public |
options: * |
|
| public |
|
|
| public get |
Called when both the form and submission have been loaded. |
|
| public |
root: * |
|
| public |
|
|
| public get |
schema: * |
|
| public |
shortcuts: *[] |
|
| public get |
Get the embed source of the form. |
|
| public set |
Set the Form source, which is typically the Form.io embed URL. |
|
| public get |
submission: Object: * Returns the submission object that was set within this form. |
|
| public set |
submission(submission: Object) Sets the submission of a form. |
|
| public |
Promise that executes when the submission is ready and rendered. |
|
| public |
Called when this form could not load and is rejected. |
|
| public |
Called when the formReady state of this form has been resolved. |
|
| public |
Determines if this submission is explicitly set. |
|
| public |
Determines if the form has tried to be submitted, error or not. |
|
| public |
Determines if the form is being submitted at the moment. |
|
| public |
|
|
| public |
The type of this element. |
|
| public get |
Get the embed source of the form. |
|
| public set |
Set the form source but don't initialize the form and submission from the url. |
|
| Private Members | ||
| private |
_form: {} |
|
| private |
|
|
| private |
_nosubmit: * |
|
| private |
|
|
| private |
_submission: * |
|
Method Summary
| Public Methods | ||
| public |
addLanguage(code: *, lang: *, active: *): * Add a language for translations |
|
| public |
addShortcut(element: *, shortcut: *) |
|
| public |
attach(element: *): * |
|
| public |
build(element: *): * |
|
| public |
Cancels the submission. |
|
| public |
checkData(data: *, flags: {}): * |
|
| public |
deleteSubmission(): * Send a delete request to the server. |
|
| public |
|
|
| public |
|
|
| public |
executeSubmit(options: *): * |
|
| public |
focusOnComponent(key: string): * Focus on selected component. |
|
| public |
getClassName(): * |
|
| public |
getValue(): * |
|
| public |
hasRequiredFields(): * |
|
| public |
init(): * Build the form. |
|
| public |
keyboardCatchableElement(element: *): boolean |
|
| public |
loadSubmission(): * Loads the submission if applicable. |
|
| public |
localize(): * Perform the localization initialization. |
|
| public |
mergeData(_this: *, _that: *) |
|
| public |
onChange(changed: *, flags: *) Trigger the change event for this form. |
|
| public |
onSubmissionError(error: Object): * Called when an error occurs during the submission. |
|
| public |
Called when the submission has completed, or if the submission needs to be sent to an external library. |
|
| public |
redraw(): * |
|
| public |
removeShortcut(element: *, shortcut: *) |
|
| public |
render(): * |
|
| public |
|
|
| public |
restoreDraft(-: userId) Restores a draft submission based on the user who is authenticated. |
|
| public |
Saves a submission draft. |
|
| public |
Sets a new alert to display in the error dialog of the form. |
|
| public |
Sets the JSON schema for the form to be rendered. |
|
| public |
setMetadata(submission: *) |
|
| public |
setSrc(value: *, options: *): * Set the src of the form renderer. |
|
| public |
setSubmission(submission: *, flags: *): Promise<TResult> Sets a submission and returns the promise when it is ready. |
|
| public |
Sets the url of the form renderer. |
|
| public |
setValue(submission: *, flags: {}): * |
|
| public |
showErrors(error: Object): * Show the errors of this form within the alert dialog. |
|
| public |
Submits the form. |
|
| public |
submitForm(options: {}): * |
|
| public |
submitUrl(URL: *, headers: *): * |
|
| public |
|
|
Public Constructors
public constructor(options: Object) source
Creates a new Form instance.
Params:
| Name | Type | Attribute | Description |
| options | Object | The options to create a new form instance. |
|
| options.saveDraft | boolean | Set this if you would like to enable the save draft feature. |
|
| options.saveDraftThrottle | boolean | The throttle for the save draft feature. |
|
| options.readOnly | boolean | Set this form to readOnly |
|
| options.noAlerts | boolean | Set to true to disable the alerts dialog. |
|
| options.i18n | boolean | The translation file for this rendering. @see https://github.com/formio/formio.js/blob/master/i18n.js |
|
| options.template | boolean | Provides a way to inject custom logic into the creation of every element rendered within the form. |
Public Members
public component: * source
public get componentComponents: * source
public components: *[] source
public currentForm: * source
public customErrors: *[] source
public editing: * source
public element: * source
public executeShortcuts: * source
public formReady: Promise source
Promise that executes when the form is ready and rendered.
Example:
import Webform from 'formiojs/Webform';
let form = new Webform(document.getElementById('formio'));
form.formReady.then(() => {
console.log('The form is ready!');
});
form.src = 'https://examples.form.io/example';
public formReadyResolve: function source
Called when the formReady state of this form has been resolved.
public set loading(loading: boolean) source
Set the loading state for this form, and also show the loader spinner.
public set nosubmit source
public get nosubmit: * source
public options: * source
public root: * source
public get schema: * source
public shortcuts: *[] source
public set src(value: string) source
Set the Form source, which is typically the Form.io embed URL.
Example:
import Webform from 'formiojs/Webform';
let form = new Webform(document.getElementById('formio'));
form.formReady.then(() => {
console.log('The form is formReady!');
});
form.src = 'https://examples.form.io/example';
public get submission: Object: * source
Returns the submission object that was set within this form.
public set submission(submission: Object) source
Sets the submission of a form.
Example:
import Webform from 'formiojs/Webform';
let form = new Webform(document.getElementById('formio'));
form.src = 'https://examples.form.io/example';
form.submission = {data: {
firstName: 'Joe',
lastName: 'Smith',
email: 'joe@example.com'
}};
public submissionReady: Promise source
Promise that executes when the submission is ready and rendered.
Example:
import Webform from 'formiojs/Webform';
let form = new Webform(document.getElementById('formio'));
form.submissionReady.then(() => {
console.log('The submission is ready!');
});
form.src = 'https://examples.form.io/example/submission/234234234234234243';
public submissionReadyResolve: function source
Called when the formReady state of this form has been resolved.
public triggerSaveDraft: * source
public set url(value: string) source
Set the form source but don't initialize the form and submission from the url.
Private Members
private _form: {} source
private _nosubmit: * source
private _submission: * source
Public Methods
public addLanguage(code: *, lang: *, active: *): * source
Add a language for translations
Params:
| Name | Type | Attribute | Description |
| code | * | ||
| lang | * | ||
| active | * |
Return:
| * |
public addShortcut(element: *, shortcut: *) source
Params:
| Name | Type | Attribute | Description |
| element | * | ||
| shortcut | * |
public cancel(noconfirm: *): boolean source
Cancels the submission.
Params:
| Name | Type | Attribute | Description |
| noconfirm | * |
public checkData(data: *, flags: {}): * source
Params:
| Name | Type | Attribute | Description |
| data | * | ||
| flags | {} |
|
Return:
| * |
public destroy(deleteFromGlobal: boolean): * source
Params:
| Name | Type | Attribute | Description |
| deleteFromGlobal | boolean |
|
Return:
| * |
public focusOnComponent(key: string): * source
Focus on selected component.
Params:
| Name | Type | Attribute | Description |
| key | string | The key of selected component. |
Return:
| * |
public keyboardCatchableElement(element: *): boolean source
Params:
| Name | Type | Attribute | Description |
| element | * |
public mergeData(_this: *, _that: *) source
Params:
| Name | Type | Attribute | Description |
| _this | * | ||
| _that | * |
public onChange(changed: *, flags: *) source
Trigger the change event for this form.
Params:
| Name | Type | Attribute | Description |
| changed | * | ||
| flags | * |
public onSubmissionError(error: Object): * source
Called when an error occurs during the submission.
Params:
| Name | Type | Attribute | Description |
| error | Object | The error that occured. |
Return:
| * |
public onSubmit(submission: Object, saved: boolean): object source
Called when the submission has completed, or if the submission needs to be sent to an external library.
public removeShortcut(element: *, shortcut: *) source
Params:
| Name | Type | Attribute | Description |
| element | * | ||
| shortcut | * |
public resetValue() source
public restoreDraft(-: userId) source
Restores a draft submission based on the user who is authenticated.
Params:
| Name | Type | Attribute | Description |
| - | userId | The user id where we need to restore the draft from. |
public setAlert(type: string, message: string, classes: string) source
Sets a new alert to display in the error dialog of the form.
public setForm(form: Object): * source
Sets the JSON schema for the form to be rendered.
Params:
| Name | Type | Attribute | Description |
| form | Object | The JSON schema of the form @see https://examples.form.io/example for an example JSON schema. |
Return:
| * |
Example:
import Webform from 'formiojs/Webform';
let form = new Webform(document.getElementById('formio'));
form.setForm({
components: [
{
type: 'textfield',
key: 'firstName',
label: 'First Name',
placeholder: 'Enter your first name.',
input: true
},
{
type: 'textfield',
key: 'lastName',
label: 'Last Name',
placeholder: 'Enter your last name',
input: true
},
{
type: 'button',
action: 'submit',
label: 'Submit',
theme: 'primary'
}
]
});
public setMetadata(submission: *) source
Params:
| Name | Type | Attribute | Description |
| submission | * |
public setSrc(value: *, options: *): * source
Set the src of the form renderer.
Params:
| Name | Type | Attribute | Description |
| value | * | ||
| options | * |
Return:
| * |
public setSubmission(submission: *, flags: *): Promise<TResult> source
Sets a submission and returns the promise when it is ready.
Params:
| Name | Type | Attribute | Description |
| submission | * | ||
| flags | * |
public setUrl(value: *, options: *): boolean source
Sets the url of the form renderer.
Params:
| Name | Type | Attribute | Description |
| value | * | ||
| options | * |
public setValue(submission: *, flags: {}): * source
Params:
| Name | Type | Attribute | Description |
| submission | * | ||
| flags | {} |
|
Return:
| * |
public showErrors(error: Object): * source
Show the errors of this form within the alert dialog.
Params:
| Name | Type | Attribute | Description |
| error | Object | An optional additional error to display along with the component errors. |
Return:
| * |
public submit(before: boolean): Promise source
Submits the form.
Params:
| Name | Type | Attribute | Description |
| before | boolean | If this submission occured from the before handlers. |
Example:
import Webform from 'formiojs/Webform';
let form = new Webform(document.getElementById('formio'));
form.src = 'https://examples.form.io/example';
form.submission = {data: {
firstName: 'Joe',
lastName: 'Smith',
email: 'joe@example.com'
}};
form.submit().then((submission) => {
console.log(submission);
});
public submitForm(options: {}): * source
Params:
| Name | Type | Attribute | Description |
| options | {} |
|
Return:
| * |
public submitUrl(URL: *, headers: *): * source
Params:
| Name | Type | Attribute | Description |
| URL | * | ||
| headers | * |
Return:
| * |
