Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

var formio = new Formio(<endpoint>, [options]);

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

const formio = new Formio('https://examples.form.io/example');
formio.loadForm().then((form) => {
console.log(form);
});

Hierarchy

  • Formio

Index

Constructors

constructor

Properties

actionId

actionId: string = ''

The Action ID derived from a provided Action url.

actionUrl

actionUrl: string = ''

A specific action api endoint.

actionsUrl

actionsUrl: string = ''

The actions url provided a form url as the source.

example

https://examples.form.io/example/action

base

base: string = ''

The base API url of the Form.io Platform. Example: https://api.form.io

formId

formId: string = ''

The Form ID derived from the provided source.

formUrl

formUrl: string = ''

A specific form url derived from the provided source.

example

https://examples.form.io/example

formsUrl

formsUrl: string = ''

The forms url derived from the provided source.

example

https://example.form.io/form

noProject

noProject: boolean = false

If this is a non-project url, such is the case for Open Source API.

options

options: FormioOptions = {}

Optional path

path?: string

Optional pathType

pathType?: FormioPathType

The project type.

projectId

projectId: string = ''

The Project ID found within the provided source.

projectUrl

projectUrl: string = ''

A specific project endpoint derived from the provided source.

example

https://examples.form.io

projectsUrl

projectsUrl: string = ''

The Projects Endpoint derived from the provided source.

example

https://api.form.io/project

query

query: string = ''

The query string derived from the provided src url.

roleId

roleId: string = ''

The roleID derieved from the provided source.

roleUrl

roleUrl: string = ''

A specific Role URL provided the source.

example

https://examples.form.io/role/2342343234234234

rolesUrl

rolesUrl: string = ''

The roles endpoint derived from the provided source.

example

https://examples.form.io/role

submissionId

submissionId: string = ''

The submission ID provided a submission url.

submissionUrl

submissionUrl: string = ''

A specific submissions URL derived from a provided source.

example

https://examples.form.io/example/submission/223423423423

submissionsUrl

submissionsUrl: string = ''

The submissions URL derived from the provided source.

example

https://examples.form.io/example/submission

vId

vId: string = ''

vUrl

vUrl: string = ''

vsUrl

vsUrl: string = ''

Static Headers

Headers: any = Headers

A direct interface to the Form.io fetch Headers polyfill.

Static authUrl

authUrl: string = ''

The project url to use for Authentication.

Static baseUrl

baseUrl: string = 'https://api.form.io'

The base API url of the Form.io Platform. Example: https://api.form.io

Static cache

cache: any = {}

The Form.io API Cache. This ensures that requests to the same API endpoint are cached.

Static deregisterPlugin

deregisterPlugin: (plugin: string | Plugin) => boolean = Plugins.deregisterPlugin

Type declaration

    • (plugin: string | Plugin): boolean
    • De-registers a plugin.

      Parameters

      • plugin: string | Plugin

        The plugin you wish to deregister.

      Returns boolean

Static events

events: EventEmitterBase<string | symbol, any> = ...

Handles events fired within this SDK library.

Static fetch

fetch: any = fetch

A direct interface to the Form.io fetch polyfill.

Static getPlugin

getPlugin: (name: string) => null | Plugin = Plugins.getPlugin

Type declaration

    • Returns a plugin provided the name of the plugin.

      Parameters

      • name: string

        The name of the plugin you would like to get.

      Returns null | Plugin

Static libraries

libraries: any = {}

Stores all of the libraries lazy loaded with Formio.requireLibrary method.

Static namespace

namespace: string = ''

The namespace used to save the Form.io Token's and variables within an application.

Static Optional pathType

pathType?: FormioPathType

The path type for the project.

Static pluginAlter

pluginAlter: (pluginFn: any, value: any, ...args: any[]) => any = Plugins.pluginAlter

Type declaration

    • (pluginFn: any, value: any, ...args: any[]): any
    • Allows a Plugin to alter the behavior of the JavaScript library.

      Parameters

      • pluginFn: any
      • value: any
      • Rest ...args: any[]

      Returns any

Static pluginGet

pluginGet: (pluginFn: any, ...args: any[]) => any = Plugins.pluginGet

Type declaration

    • (pluginFn: any, ...args: any[]): any
    • Gets a value from a Plugin

      Parameters

      • pluginFn: any
      • Rest ...args: any[]

      Returns any

Static pluginWait

pluginWait: (pluginFn: any, ...args: any[]) => Promise<any[]> = Plugins.pluginWait

Type declaration

    • (pluginFn: any, ...args: any[]): Promise<any[]>
    • Wait for a plugin function to complete.

      Parameters

      • pluginFn: any

        A function within the plugin.

      • Rest ...args: any[]

      Returns Promise<any[]>

Static plugins

plugins: Plugin[] = Plugins.plugins

Static projectUrl

projectUrl: string = ''

The project API url of the Form.io Project. Example: https://examples.form.io

Static projectUrlSet

projectUrlSet: boolean = false

Set to true if the project url has been established with Formio.setProjectUrl()

Static registerPlugin

registerPlugin: (plugin: Plugin, name: string) => void = Plugins.registerPlugin

Type declaration

    • (plugin: Plugin, name: string): void
    • Registers a new plugin.

      Parameters

      • plugin: Plugin

        The Plugin object.

      • name: string

        The name of the plugin you wish to register.

      Returns void

Static tokens

tokens: any = {}

All of the auth tokens for this session.

Static version

version: string = '---VERSION---'

The version of this library.

Accessors

Static token

  • get token(): any
  • set token(token: any): void

Methods

accessInfo

  • accessInfo(): any

actionInfo

  • actionInfo(name: string): any
  • 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);
    });

    Parameters

    • name: string

      The name of the action you would like to get information for. i.e. "save", "webhook", etc.

    Returns any

availableActions

  • availableActions(): any

canSubmit

  • canSubmit(): Promise<any>

currentUser

  • currentUser(options?: any): any

delete

  • delete(type: string, opts?: any): any
  • Deletes a remote resource of any provided type.

    Parameters

    • type: string

      The type of resource to delete. "submission", "form", etc.

    • Optional opts: any

    Returns any

deleteAction

  • deleteAction(opts?: any): any
  • Delete an action

    const formio = new Formio('https://examples.form.io/example/action/234234234234');
    formio.deleteAction().then(() => {
    console.log('Action was deleted.');
    });

    Parameters

    • Optional opts: any

    Returns any

deleteForm

  • deleteForm(opts?: any): any
  • Deletes a form.

    const formio = new Formio('https://examples.form.io/example');
    formio.deleteForm().then(() => {
    console.log('Deleted!');
    });

    Parameters

    • Optional opts: any

    Returns any

deleteProject

  • deleteProject(opts?: any): any
  • Deletes a project

    const formio = new Formio('https://examples.form.io');
    formio.deleteProject();

    Parameters

    • Optional opts: any

    Returns any

deleteRole

  • deleteRole(opts?: any): any
  • Deletes a role within a project.

    Parameters

    • Optional opts: any

    Returns any

deleteSubmission

  • deleteSubmission(opts?: any): any

getDownloadUrl

  • getDownloadUrl(form: any): any
  • 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);
    });

    Parameters

    • form: any

    Returns any

    • The download url.

getFormId

  • getFormId(): any
  • Get the ID of a form.

    const formio = new Formio('https://examples.form.io/example');
    formio.getFormId().then((formId) => {
    console.log(formId);
    });

    Returns any

getProjectId

  • getProjectId(): any
  • Get the project ID of project.

    const formio = new Formio('https://examples.form.io');
    formio.getProjectId().then((projectId) => {
    console.log(projectId);
    };

    Returns any

getTempToken

  • getTempToken(expire: any, allowed: string, options?: any): any
  • Returns a temporary authentication token for single purpose token generation.

    Parameters

    • expire: any

      The amount of seconds to wait before this temp token expires.

    • allowed: string

      The allowed path string inn the format GET:/path

    • Optional options: any

      The options passed to {@link Formio#getToken}

    Returns any

getToken

  • getToken(options?: any): any
  • Returns the JWT token for this instance.

    Parameters

    • Optional options: any

      The following options are provided.

    Returns any

    • The JWT token for this user.

getUrlParts

  • getUrlParts(url: string): null | RegExpMatchArray

index

  • index(type: string, query?: any, opts?: any): any
  • Returns the index (array of records) for any provided type.

    Parameters

    • type: string

      The type of resource to fetch the index of. "submission", "form", etc.

    • Optional query: any

      A query object to pass to the request.

    • Optional opts: any

    Returns any

isObjectId

  • isObjectId(id: string): boolean
  • Determine if a string ID is a valid MongoID.

    Parameters

    • id: string

      The id that should be tested if it is avalid id.

    Returns boolean

    • true if it is a valid MongoId, false otherwise.

load

  • load(type: string, query?: any, opts?: any): any
  • summary

    Load (GET) a document record.

    Parameters

    • type: string

      The type of resource to fetch the index of. "submission", "form", etc.

    • Optional query: any

      A query object to pass to the request.

    • Optional opts: any

    Returns any

loadAction

  • loadAction(query?: any, opts?: any): any
  • Loads a form action.

    const formio = new Formio('https://examples.form.io/example/action/234234234234');
    formio.loadAction().then((action) => {
    console.log(action);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

loadActions

  • loadActions(query?: any, opts?: any): any
  • Loads all actions within a form.

    const formio = new Formio('https://examples.form.io/example');
    formio.loadActions().then((actions) => {
    console.log(actions);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

loadForm

  • loadForm(query?: any, opts?: any): any
  • Loads a form.

    const formio = new Formio('https://examples.form.io/example');
    formio.loadForm().then((form) => {
    console.log(form);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

loadForms

  • loadForms(query?: any, opts?: any): any
  • Loads all forms within a project.

    const formio = new Formio('https://examples.form.io');
    formio.loadForms().then((forms) => {
    console.log(forms);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

loadProject

  • loadProject(query?: any, opts?: any): any
  • summary

    Loads a project.

    const formio = new Formio('https://examples.form.io');
    formio.loadProject().then((project) => {
    console.log(project);
    });

    Parameters

    • Optional query: any

      Query parameters to pass to {@link Formio#load}.

    • Optional opts: any

    Returns any

loadRole

  • loadRole(opts?: any): any
  • Loads a role within a project.

    const formio = new Formio('https://examples.form.io/role/234234234234');
    formio.loadRole().then((role) => {
    console.log(role);
    });

    Parameters

    • Optional opts: any

    Returns any

loadRoles

  • loadRoles(opts?: any): any
  • Load all roles within a project.

    const formio = new Formio('https://examples.form.io');
    formio.loadRoles().then((roles) => {
    console.log(roles);
    });

    Parameters

    • Optional opts: any

    Returns any

loadSubmission

  • loadSubmission(query?: any, opts?: any): any
  • Loads a specific submissionn.

    const formio = new Formio('https://examples.form.io/example/submission/23423423423423423');
    formio.loadSubmission().then((submission) => {
    console.log(submission);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

loadSubmissions

  • loadSubmissions(query?: any, opts?: any): any
  • 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);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

makeRequest

  • makeRequest(type: string, url: string, method?: string, data?: any, opts?: any): any
  • summary

    Call Formio.makeRequest for this Formio instance.

    Parameters

    • type: string

      The request resource type. "submission", "form", etc.

    • url: string

      The URL to request.

    • Optional method: string

      The request method. GET, PUT, POST, DELETE, or PATCH

    • Optional data: any

      The data to pass to the request (for PUT, POST, and PATCH methods)

    • Optional opts: any

    Returns any

save

  • save(type: string, data?: any, opts?: any): any
  • 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.

    Parameters

    • type: string

      The type of resource to fetch the index of. "submission", "form", etc.

    • Optional data: any

      The resource data object.

    • Optional opts: any

    Returns any

saveAction

  • saveAction(data?: any, opts?: any): any
  • Create a new or update an existing action.

    Create a new action for a form.

    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);
    });

    Update an 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!');
    });
    });

    Parameters

    • Optional data: any

      The action JSON

    • Optional opts: any

    Returns any

saveForm

  • saveForm(data?: any, opts?: any): any
  • Create or Update a specific form.

    Create form example

    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'
    }
    ]
    });

    Update a form example

    const formio = new Formio('https://examples.form.io/example');
    formio.loadForm().then((form) => {
    form.title = 'Changed Title';
    formio.saveForm(form).then(() => {
    console.log('DONE!!!');
    });
    });

    Parameters

    • Optional data: any

      The Form JSON to create or update.

    • Optional opts: any

    Returns any

saveProject

  • saveProject(data?: any, opts?: any): any
  • Saves or Updates a project.

    Create a new project

    const formio = new Formio();
    formio.saveProject({
    title: 'My Project',
    path: 'myproject',
    name: 'myproject'
    });

    Update an existing project

    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!');
    });
    });

    Parameters

    • Optional data: any

      The project JSON to create or update.

    • Optional opts: any

    Returns any

saveRole

  • saveRole(data?: any, opts?: any): any
  • Create a new or Update an existing role within a project.

    Create new Role example

    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);
    });

    Update existing role example

    const formio = new Formio('https://examples.form.io/role/234234234234234');
    formio.loadRole().then((role) => {
    role.title = 'Manager';
    formio.saveRole(role).then(() => {
    console.log('DONE');
    });
    });

    Parameters

    • Optional data: any
    • Optional opts: any

    Returns any

saveSubmission

  • saveSubmission(data?: any, opts?: any): any
  • Creates a new or Updates an existing submission.

    Create a new 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);
    });

    Update an existing 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');
    });
    });

    Parameters

    • Optional data: any

      The submission JSON object.

    • Optional opts: any

    Returns any

setToken

  • setToken(token: any, options?: any): any
  • Sets the JWT token for this instance.

    Parameters

    • token: any

      The JWT token to set.

    • Optional options: any

      The following options are provided.

    Returns any

    • The JWT token that was set.

userPermissions

  • userPermissions(user?: any, form?: any, submission?: any): Promise<any>
  • Returns the user permissions to a form and submission.

    Parameters

    • Optional user: any

      The user or current user if undefined. For anonymous, use "null"

    • Optional form: any

      The form or current form if undefined. For no form check, use "null"

    • Optional submission: any

      The submisison or "index" if undefined.

    Returns Promise<any>

Static accessInfo

  • accessInfo(formio?: any): any
  • 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.

    description

    This is useful for an application to determine the UI for a specific user to identify which forms they have access to submit or read.

    Parameters

    • Optional formio: any

      The Formio instance.

    Returns any

Static clearCache

  • clearCache(): void
  • Clears the runtime internal API cache.

    description

    By default, the Formio class will cache all API requests in memory so that any subsequent requests using GET method will return the cached results as long as the API URl is the same as what was cached previously. This cache can be cleared using this method as follows.

    Formio.clearCache();
    

    Or, if you just wish to clear a single request, then the {@link Formio.request#options.ignoreCache} option can be provided when making an API request as follows.

    Formio.loadForm({}, {
    ignoreCache: true
    }).then((form) => {
    console.log(form);
    });

    Both of the following will ensure that a new request is made to the API server and that the results will not be from the cached result.

    Returns void

Static cloneResponse

  • cloneResponse(response: any): any
  • Clones the response from the API so that it cannot be mutated.

    Parameters

    • response: any

    Returns any

Static currentUser

  • currentUser(formio?: any, options?: any): any
  • Return the currentUser object. This will fetch the user from the server and respond with the Submission JSON of that user object.

    Parameters

    • Optional formio: any

      The Formio instance

    • options: any = {}

      The options passed to Formio.getUser

    Returns any

Static getApiUrl

  • getApiUrl(): string

Static getAppUrl

  • getAppUrl(): string

Static getBaseUrl

  • getBaseUrl(): string

Static getPathType

Static getProjectUrl

  • getProjectUrl(): string

Static getRequestArgs

  • getRequestArgs(formio: any, type: string, url: string, method?: any, data?: any, opts?: any): any
  • Parameters

    • formio: any
    • type: string
    • url: string
    • Optional method: any
    • Optional data: any
    • Optional opts: any

    Returns any

Static getToken

  • getToken(options?: any): any
  • Returns the token set within the application for the user.

    Parameters

    • Optional options: any

      The options as follows.

    Returns any

Static getUrlParts

  • getUrlParts(url: string, formio: any): null | RegExpMatchArray

Static getUser

  • getUser(options?: any): any
  • Returns the user JSON.

    Parameters

    • Optional options: any

      Options as follows

    Returns any

    • The user object.

Static libraryReady

  • libraryReady(name: string): any
  • Determines if a lazy loaded library is ready to be used.

    description

    Example: Let's assume that the example provided at Formio.requireLibrary was used elsewhere in your application. You could now use the following within a separate place that will also resolve once the library is ready to be used.

    Formio.libraryReady('googleMaps').then(() => {
    // Once the promise resolves, the following can now be used within your application.
    const map = new google.maps.Map(document.getElementById("map"), {...});
    });

    Parameters

    • name: string

      The name of the library to check.

    Returns any

    • A promise that will resolve when the library is ready to be used.

Static loadProjects

  • loadProjects(query?: any, opts?: any): any
  • Loads a list of all projects.

    Formio.loadProjects().then((projects) => {
    console.log(projects);
    });

    Parameters

    • Optional query: any

      Query parameters similar to {@link Formio#load}.

    • Optional opts: any

    Returns any

Static logout

  • logout(formio?: any, options?: any): any
  • 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.

    Parameters

    Returns any

Static makeRequest

  • makeRequest(formio: any, type: string, url: string, method?: string, data?: any, opts?: any): any
  • 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.

    Parameters

    • formio: any

      An instance of the Formio class.

    • type: string

      The request resource type. "submission", "form", etc.

    • url: string

      The URL to request.

    • Optional method: string

      The request method. GET, PUT, POST, DELETE, or PATCH

    • Optional data: any

      The data to pass to the request (for PUT, POST, and PATCH methods)

    • Optional opts: any

    Returns any

Static makeStaticRequest

  • makeStaticRequest(url: string, method?: any, data?: any, opts?: any): any
  • Parameters

    • url: string
    • Optional method: any
    • Optional data: any
    • Optional opts: any

    Returns any

Static oAuthCurrentUser

  • oAuthCurrentUser(formio: any, token: string): any
  • 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.

    Parameters

    • formio: any

      The Formio instance

    • token: string

      An OAuth Bearer token to use for a token swap between the OAuth provider and Form.io

    Returns any

Static oktaInit

  • oktaInit(options?: any): Promise<unknown>
  • Perform an Okta Authentication process using the Okta SDK.

    description

    This method does require that you first include the Okta JavaScript SDK within your application as follows.

    First you need to include the Okta Authentication script.

    <script src="https://ok1static.oktacdn.com/assets/js/sdk/okta-auth-js/2.0.1/okta-auth-js.min.js" type="text/javascript"></script>
    

    Then you can call this method as follows.

    Formio.oktaInit();
    

    Parameters

    Returns Promise<unknown>

Static pageQuery

  • pageQuery(): any
  • Returns the query passed to a page in JSON object format.

    description

    For example, lets say you visit your application using the url as follows.

      https://yourapplication.com/?token=23423423423&username=Joe
    

    The following code will provide your application with the following.

    const query Formio.pageQuery();
    console.log(query.token); // Will print 23423423423
    console.log(query.username); // Will print Joe

    Returns any

    • A JSON object representation of the query that was passed to the URL of an application.

Static projectRoles

  • projectRoles(formio?: any): any
  • Returns an array of roles for the project, which includes the ID's and names of those roles.

    Parameters

    • Optional formio: any

      The Formio instance.

    Returns any

Static request

  • request(url: string, method?: any, data?: any, header?: any, opts?: any): any
  • 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);
    });

    Parameters

    • url: string

      The URL to request.

    • Optional method: any

      The request method. GET, PUT, POST, DELETE, or PATCH

    • Optional data: any

      The data to pass to the request (for PUT, POST, and PATCH methods)

    • Optional header: any

      An object of headers to pass to the request.

    • Optional opts: any

    Returns any

Static requireLibrary

  • requireLibrary(name: string, property: string, src: string | string[], polling?: boolean): any
  • Lazy load a remote library dependency.

    description

    This is useful for components that wish to lazy load a required library by adding that library to the section of the HTML webpage, and then provide a promise that will resolve when the library becomes available for use.

    example

    Load Google Maps API.

    Formio.requireLibrary('googleMaps', 'google.maps.Map', 'https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap', true).then(() => {
    // Once the promise resolves, the following can now be used within your application.
    const map = new google.maps.Map(document.getElementById("map"), {...});
    });

    Parameters

    • name: string

      The internal name to give to the library you are loading. This is useful for caching the library for later use.

    • property: string

      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.

    • src: string | string[]

      The URL of the library to lazy load.

    • polling: boolean = false

      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.

    Returns any

    • A promise that will resolve when the plugin is ready to be used.

Static samlInit

  • samlInit(options?: any): any
  • Perform a SAML initialization.

    description

    Typically, you would use the Formio.ssoInit method to perform this function since this method is an alias for the following.

    Formio.samlInit();
    Formio.ssoInit('saml'); // This is the exact same thing as calling Formio.samlInit

    This method will return false if the process is just starting. The code below is a typical block of code that is used to automatically trigger the SAML authentication process within your application using a Button component.

    if (Formio.pageQuery().saml) {
    const sso = Formio.samlInit();
    if (sso) {
    sso.then((user) => {
    // The SSO user is now loaded!
    console.log(user);
    });
    }
    }

    You can then place the following code withiin the "Custom" action of a Button component on your form.

    Formio.samlInit();
    

    Now when you click on this button, it will start the handshake process with SAML, and once it returns, will pass a "saml" query parameter back to your application which will execute the code to load the current user from SAML.

    Parameters

    • options: any = {}

      Options to pass to the SAML initialization process.

    Returns any

Static serialize

  • serialize(obj: any, _interpolate?: any): string

Static setApiUrl

  • setApiUrl(url: string): void

Static setAppUrl

  • setAppUrl(url: string): void

Static setAuthUrl

  • setAuthUrl(url: string): void
  • 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

    Parameters

    • url: string

      The authentication url

    Returns void

Static setBaseUrl

  • setBaseUrl(url: string): void
  • Sets the BaseURL for the application.

    description

    Every application developed using the JavaScript SDK must set both the Formio.setBaseUrl and Formio.setProjectUrl methods. These two functions ensure that every URL passed into the constructor of this class can determine the "project" context for which the application is running.

    Any Open Source server applications will set both the Formio.setBaseUrl and Formio.setProjectUrl values will be the same value.

    Formio.setBaseUrl('https://yourwebsite.com/forms');
    Formio.setProjectUrl('https://yourwebsite.com/forms/project');

    // Now the Formio constructor will know what is the "project" and what is the form alias name. Without setBaseUrl
    // and setProjectUrl, this would throw an error.

    const formio = new Formio('https://yourwebsite.com/forms/project/user');
    formio.loadForm().then((form) => {
    console.log(form);
    });

    Parameters

    • url: string

      The URL of the Base API url.

    Returns void

Static setPathType

Static setProjectUrl

  • setProjectUrl(url: string): void
  • 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.

    Parameters

    • url: string

      The project api url.

    Returns void

Static setToken

  • setToken(token?: any, opts?: any): any
  • Sets the JWT in storage to be used within an application.

    Parameters

    • token: any = ''

      The JWT token to set.

    • opts: any = {}

    Returns any

Static setUser

  • setUser(user: any, opts?: any): void
  • Sets the current user within the application cache.

    Parameters

    • user: any

      JSON object of the user you wish to set.

    • opts: any = {}

    Returns void

Static ssoInit

  • ssoInit(type: string, options?: any): any
  • A common static method to trigger any SSO processes. This method is really just an alias for other static methods.

    Parameters

    • type: string

      The type of SSO to trigger. 'saml' is an alias for Formio.samlInit, and 'okta' is an alias for Formio.oktaInit.

    • options: any = {}

      Options to pass to the specific sso methods

    Returns any

Generated using TypeDoc