Intro to Superform API
Harness the full power of Superform with our JavaScript SDK.
Getting Started
Initializing the Superform API is pretty simple. Check out this JavaScript example below:
When to Use the Superform API?
Superform is powerful — out of the box. However, if something is not supported and you wish to extend Superform's functionalities, you can use the Superform API. We picked the best use cases you might want to use the Superform API for:
Global Superform API
The following APIs are available to interact with Superform.
Superform
Class
Superform
ClassWith the Superform
class, you can manually initialize Superform. Make sure not to include the sf
attribute on your form container.
Syntax
formName
string
The name or selector of the form container
Returns
A form instance
Superform Instance
Returns a Superform instance associated with the specified container
Usage example:
getForm(formName)
getForm(formName)
Allows you to get a form by name if it is auto-initialized using the sf
attribute.
Syntax
formName
string
The name of the form to retrieve
Returns
A form instance
Superform Instance
Returns a Superform instance if it exists, otherwise undefined
Usage example:
allForms()
allForms()
Allows you to get an array of all initialized Superform instances.
Syntax
All forms
Array
An array containing all Superform instances
Usage example:
Managing Superform Instances
For advanced control of Superform instances and learn how to:
Retrieve Form Data: Access form values programmatically with
getFormData
.Event Listeners: Utilize
beforeStepChange
,onStepChange
, andonFormSubmit
for custom actions.Register Hooks: Implement custom logic using
registerInputValidationHook
andregisterNavigationHook
.
Visit the Superform Instance documentation.
Last updated