A project, form, and submission API Url.
Available options to configure the Javascript API.
The Action ID derived from a provided Action url.
A specific action api endoint.
The actions url provided a form url as the source.
The base API url of the Form.io Platform. Example: https://api.form.io
The Form ID derived from the provided source.
A specific form url derived from the provided source.
The forms url derived from the provided source.
If this is a non-project url, such is the case for Open Source API.
The project type.
The Project ID found within the provided source.
A specific project endpoint derived from the provided source.
The Projects Endpoint derived from the provided source.
The query string derived from the provided src url.
The roleID derieved from the provided source.
A specific Role URL provided the source.
The roles endpoint derived from the provided source.
The submission ID provided a submission url.
A specific submissions URL derived from a provided source.
The submissions URL derived from the provided source.
A direct interface to the Form.io fetch Headers polyfill.
The project url to use for Authentication.
The base API url of the Form.io Platform. Example: https://api.form.io
The Form.io API Cache. This ensures that requests to the same API endpoint are cached.
De-registers a plugin.
The plugin you wish to deregister.
Handles events fired within this SDK library.
A direct interface to the Form.io fetch polyfill.
Returns a plugin provided the name of the plugin.
The name of the plugin you would like to get.
Stores all of the libraries lazy loaded with Formio.requireLibrary
method.
The namespace used to save the Form.io Token's and variables within an application.
The path type for the project.
Allows a Plugin to alter the behavior of the JavaScript library.
Gets a value from a Plugin
Wait for a plugin function to complete.
A function within the plugin.
The project API url of the Form.io Project. Example: https://examples.form.io
Set to true if the project url has been established with Formio.setProjectUrl()
Registers a new plugin.
The Plugin object.
The name of the plugin you wish to register.
All of the auth tokens for this session.
The version of this library.
Instance method for Formio.accessInfo
Returns the action information for a specific action, such as "save".
const formio = new Formio('https://examples.form.io/example/actions/save');
formio.actionInfo().then((info) => {
console.log(info);
});
The name of the action you would like to get information for. i.e. "save", "webhook", etc.
Returns a list of available actions
`Determine if the current user can submit a form.
Instance method for Formio.currentUser
Options to pass to Formio.request
Deletes a remote resource of any provided type.
The type of resource to delete. "submission", "form", etc.
Delete an action
const formio = new Formio('https://examples.form.io/example/action/234234234234');
formio.deleteAction().then(() => {
console.log('Action was deleted.');
});
Deletes a form.
const formio = new Formio('https://examples.form.io/example');
formio.deleteForm().then(() => {
console.log('Deleted!');
});
Deletes a project
const formio = new Formio('https://examples.form.io');
formio.deleteProject();
Deletes a role within a project.
Deletes a submission.
Get a PDF download url for a submission, which will generate a new PDF of the submission. This method will first fetch a temporary download token, and then append this to the download url for this form.
const formio = new Formio('https://examples.form.io/example/submission/324234234234234');
formio.getDownloadUrl().then((url) => {
console.log(url);
});
Get the ID of a form.
const formio = new Formio('https://examples.form.io/example');
formio.getFormId().then((formId) => {
console.log(formId);
});
Get the project ID of project.
const formio = new Formio('https://examples.form.io');
formio.getProjectId().then((projectId) => {
console.log(projectId);
};
Returns a temporary authentication token for single purpose token generation.
The amount of seconds to wait before this temp token expires.
The allowed path string inn the format GET:/path
The options passed to {@link Formio#getToken}
Returns the JWT token for this instance.
The following options are provided.
Returns the index (array of records) for any provided type.
The type of resource to fetch the index of. "submission", "form", etc.
A query object to pass to the request.
Determine if a string ID is a valid MongoID.
The id that should be tested if it is avalid id.
The type of resource to fetch the index of. "submission", "form", etc.
A query object to pass to the request.
Loads a form action.
const formio = new Formio('https://examples.form.io/example/action/234234234234');
formio.loadAction().then((action) => {
console.log(action);
});
Query parameters similar to {@link Formio#load}.
Loads all actions within a form.
const formio = new Formio('https://examples.form.io/example');
formio.loadActions().then((actions) => {
console.log(actions);
});
Query parameters similar to {@link Formio#load}.
Loads a form.
const formio = new Formio('https://examples.form.io/example');
formio.loadForm().then((form) => {
console.log(form);
});
Query parameters similar to {@link Formio#load}.
Loads all forms within a project.
const formio = new Formio('https://examples.form.io');
formio.loadForms().then((forms) => {
console.log(forms);
});
Query parameters similar to {@link Formio#load}.
Query parameters to pass to {@link Formio#load}.
Loads a role within a project.
const formio = new Formio('https://examples.form.io/role/234234234234');
formio.loadRole().then((role) => {
console.log(role);
});
Load all roles within a project.
const formio = new Formio('https://examples.form.io');
formio.loadRoles().then((roles) => {
console.log(roles);
});
Loads a specific submissionn.
const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');
formio.loadSubmission().then((submission) => {
console.log(submission);
});
Query parameters similar to {@link Formio#load}.
Loads all submissions within a form.
const formio = new Formio('https://examples.form.io/example');
formio.loadSubmissions({
params: {
limit: 25,
'data.lastName__regex': 'smith'
}
}).then((submissions) => {
// Should print out 25 submissions where the last name contains "smith".
console.log(submissions);
});
Query parameters similar to {@link Formio#load}.
The request resource type. "submission", "form", etc.
The URL to request.
The request method. GET, PUT, POST, DELETE, or PATCH
The data to pass to the request (for PUT, POST, and PATCH methods)
Save a document record using "upsert". If the document does not exist, it will be created, if the _id is provided, it will be updated.
The type of resource to fetch the index of. "submission", "form", etc.
The resource data object.
Create a new or update an existing action.
const formio = new Formio('https://examples.form.io/example');
formio.saveAction({
data: {
name: 'webhook',
title: 'Webhook Action',
method: ['create', 'update', 'delete'],
handler: ['after'],
condition: {},
settings: {
url: 'https://example.com',
headers: [{}],
block: false,
forwardHeaders: false
}
}
}).then((action) => {
console.log(action);
});
const formio = new Formio('https://examples.form.io/example/action/234234234234');
formio.loadAction().then((action) => {
action.title = 'Updated title';
formio.saveAction(action).then(() => {
console.log('Done!');
});
});
The action JSON
Create or Update a specific form.
const formio = new Formio('https://examples.form.io');
formio.saveForm({
title: 'Employee',
type: 'resource',
path: 'employee',
name: 'employee',
components: [
{
type: 'textfield',
key: 'firstName',
label: 'First Name'
},
{
type: 'textfield',
key: 'lastName',
label: 'Last Name'
}
]
});
const formio = new Formio('https://examples.form.io/example');
formio.loadForm().then((form) => {
form.title = 'Changed Title';
formio.saveForm(form).then(() => {
console.log('DONE!!!');
});
});
The Form JSON to create or update.
Saves or Updates a project.
const formio = new Formio();
formio.saveProject({
title: 'My Project',
path: 'myproject',
name: 'myproject'
});
const formio = new Formio('https://examples.form.io');
formio.loadProject().then((project) => {
project.title = 'Title changed';
formio.saveProject(project).then(() => {
console.log('Done saving project!');
});
});
The project JSON to create or update.
Create a new or Update an existing role within a project.
const formio = new Formio('https://examples.form.io');
formio.saveRole({
title: 'Employee',
description: 'A person who belongs to a company.'
}).then((role) => {
console.log(role);
});
const formio = new Formio('https://examples.form.io/role/234234234234234');
formio.loadRole().then((role) => {
role.title = 'Manager';
formio.saveRole(role).then(() => {
console.log('DONE');
});
});
Creates a new or Updates an existing submission.
const formio = new Formio('https://examples.form.io/example');
formio.saveSubmission({
data: {
firstName: 'Joe',
lastName: 'Smith'
}
}).then((submission) => {
// This will now be the complete submission object saved on the server.
console.log(submission);
});
const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');
formio.loadSubmission().then((submission) => {
submission.data.lastName = 'Thompson';
formio.saveSubmission(submission).then(() => {
console.log('DONE');
});
});
The submission JSON object.
Sets the JWT token for this instance.
The JWT token to set.
The following options are provided.
Returns the user permissions to a form and submission.
The user or current user if undefined. For anonymous, use "null"
The form or current form if undefined. For no form check, use "null"
The submisison or "index" if undefined.
Return the access information about a Project, such as the Role ID's for that project, and if the server is configured to do so, the Form and Resource access configurations that the authenticated user has access to.
The Formio instance.
Clears the runtime internal API cache.
Clones the response from the API so that it cannot be mutated.
Return the currentUser object. This will fetch the user from the server and respond with the Submission JSON of that user object.
The Formio instance
The options passed to Formio.getUser
Returns the current base url described at Formio.setBaseUrl
Gets the project path type.
Returns the Project url described at Formio.setProjectUrl
Returns the token set within the application for the user.
The options as follows.
Returns the user JSON.
Options as follows
Determines if a lazy loaded library is ready to be used.
The name of the library to check.
Loads a list of all projects.
Formio.loadProjects().then((projects) => {
console.log(projects);
});
Query parameters similar to {@link Formio#load}.
Performs a logout of the Form.io application. This will reset all cache, as well as make a request to the logout endpoint of the Form.io api platform.
A Formio instance.
Options passed to both Formio.setToken as well as Formio.setUser
Make an API request and wrap that request with the Form.io Request plugin system. This is very similar to the {Formio.request} method with a difference being that it will pass the request through the Form.io request plugin.
An instance of the Formio class.
The request resource type. "submission", "form", etc.
The URL to request.
The request method. GET, PUT, POST, DELETE, or PATCH
The data to pass to the request (for PUT, POST, and PATCH methods)
Much like Formio.currentUser, but instead automatically injects the Bearer tokens into the headers to perform a Token swap of the OAuth token which will then return the JWT token for that user.
The Formio instance
An OAuth Bearer token to use for a token swap between the OAuth provider and Form.io
Perform an Okta Authentication process using the Okta SDK.
Options that are passed directly to the Okta SDK constructor
Returns the query passed to a page in JSON object format.
Returns an array of roles for the project, which includes the ID's and names of those roles.
The Formio instance.
Execute an API request to any external system. This is a wrapper around the Web fetch method.
Formio.request('https://examples.form.io').then((form) => {
console.log(form);
});
The URL to request.
The request method. GET, PUT, POST, DELETE, or PATCH
The data to pass to the request (for PUT, POST, and PATCH methods)
An object of headers to pass to the request.
Lazy load a remote library dependency.
The internal name to give to the library you are loading. This is useful for caching the library for later use.
The name of the global property that will be added to the global namespace once the library has been loaded. This is used to check to see if the property exists before resolving the promise that the library is ready for use.
The URL of the library to lazy load.
Determines if polling should be used to determine if they library is ready to use. If set to false, then it will rely on a global callback called ${name}Callback where "name" is the first property passed to this method. When this is called, that will indicate when the library is ready. In most cases, you will want to pass true to this parameter to initiate a polling method to check for the library availability in the global context.
Perform a SAML initialization.
Options to pass to the SAML initialization process.
The Auth URL can be set to customize the authentication requests made from an application. By default, this is just the same value as Formio.projectUrl
The authentication url
Sets the BaseURL for the application.
The URL of the Base API url.
Sets the project path type.
Sets the Project Url for the application. This is an important method that needs to be set for all applications. It is documented @ Formio.setBaseUrl.
The project api url.
Sets the JWT in storage to be used within an application.
The JWT token to set.
Sets the current user within the application cache.
JSON object of the user you wish to set.
A common static method to trigger any SSO processes. This method is really just an alias for other static methods.
The type of SSO to trigger. 'saml' is an alias for Formio.samlInit, and 'okta' is an alias for Formio.oktaInit.
Options to pass to the specific sso methods
Generated using TypeDoc
The Formio interface class. This is a minimalistic API library that allows you to work with the Form.io API's within JavaScript.
Usage
Creating an instance of Formio is simple, and takes only a path (URL String). The path can be different, depending on the desired output. The Formio instance can also access higher level operations, depending on how granular of a path you start with.
Where endpoint is any valid API endpoint within Form.io. These URL's can provide a number of different methods depending on the granularity of the endpoint. This allows you to use the same interface but have access to different methods depending on how granular the endpoint url is. options is defined within the {link Formio.constructor} documentation.
Here is an example of how this library can be used to load a form JSON from the Form.io API's