Modules
Describes the Form.io Module system
Last updated
Describes the Form.io Module system
Last updated
Modules allow developers to create encapsulated module bundles that alter the behavior of the Form.io Builder and Renderer. The Form Module is located within your Stage settings.
Modules were introduced in formio.js v4.5.0. You need a version later than that to utilize modules. The Form.io Renderer allows for a number of plugins, which allows for external libraries the ability to alter the behavior of this library. Each plugin is defined in a module using a simple key-pair map like the following illustrates.
The following plugins can be provided within a module.
Plugin | Description |
components | Allows for Custom Components to be introduced into the renderer. |
templates | Allows for you to introduce new templates and CSS frameworks (such as Bootstrap, Semantic, etc) |
providers | Allows for custom storage providers for file components |
displays | Provides a way to provide new and override the form renderer displays. |
builders | Provides a way to provide new and override the form builders |
options | Allows a way to override options passed into the renderer and the builder. |
fetch | Provides a way to intercept all API requests made into the Form.io renderer. |
framework | Allows for the CSS framework to be forced when loaded. |
New modules can be created by including an external Library within your application that has exports the following structure.
Each of the keys within this object are called Plugins and they each have their own object definitions as follows
Once you have a module created, it is very easy to use the module within the Form.io renderer. You simply import the module, and then use the Formio.use
method to use it. The following is an example of how a module is used.
A module consists of a bunch of plugins that are provided to the module via the "name" of the plugin. The following plugins are available for modules.
This sets the default "style" framework.
Example
Provides a way to override existing components, or introduce new components to the renderer/builder. Here is a simple of example of adding a new component.
For an example of a custom component module, take a look at the Contrib Module
Introduces new templates to the renderer for use with custom components or for overriding existing templates. See Form Templates section for more details.
Allows a custom "fetch" plugin to be utilized for this renderer. All API requests will then be sent through this fetch plugin instead of the default Formio.fetch interface (which is the standard Web fetch interface). For detailed documentation, please see the Fetch Plugin API documentation.
Allows the introduction of different providers as follows.
Provider | Description |
storage | Storage providers allow file upload interfaces. Such as Azure Blob, Dropbox, etc. For examples, go to https://github.com/formio/formio.js/tree/master/src/providers/storage |
auth | Authentication providers such as Okta, OAuth, SAML, etc. For examples, go to https://github.com/formio/formio.js/tree/master/src/providers/auth |
address | Address providers such as Google Maps, Open Street Maps, etc. For examples, go to https://github.com/formio/formio.js/tree/master/src/providers/address |
Introduces new or overrides existing Display interfaces, such as Wizard, Form, or PDF
Introduces new or overrides existing validation rules. Coming soon.
Allows the overriding of Form and Builder options. Must be in the following format.
See Form Options and Builder Options.
To register the module into the renderer, you must use the use
method, whereas you will pass the Module definition into this method.
Example