Comment on page
Context API
Common API functionality across advanced logic, event handlers, and the context ref.
All of these properties are available via advanced logic, event handlers, and the contextRef object. Specific events may also have additional properties unique to them. To see these properties, check out the documentation for the corresponding event handler.
Key | Type | Description |
---|---|---|
userId | string | The ID of the user in the current form session |
fields | { [fieldKey: string]: Field } | A mapping that contains all fields on any of your forms. Its key is the field ID and value is a Field object. Use the Field object to read/write a field value, options, error message, etc. |
getStepProperties | () => { totalSteps: number, stepName: string, previousStepName: string, backgroundColor: hex string } | Returns useful information about the current step of the form, including its name, the name of the previous step, the background color of the step, and the total number of steps in the form. |
goToStep | function | If you want to reroute the user to a different step, pass goToStep the ID of the new step to route to. For example, goToStep('new-step') |
setProgress | (number | { progress?: number; segments ?: number }) => {} | Set the amount of the progress bar on the current step. Pass in either a number from 0 - 100 or if you want a segmented progress bar, you can pass in both the progress amount and the number of segments you want the progress bar to be broken into. |
setFormCompletion | function | Pass in a boolean flag to set the user's completion status for this form. |
validateStep | (showErrors = true) => { [fieldKey: string]: string | string[] } | Runs default form validation on the current step. Triggers built-in field validation along with custom validation rules specified from the dashboard. Errors will be shown unless false is passed for showErrors.
Returns an error message per field, or an empty string if the field is valid. |
isLastStep | () => boolean | Returns True when the current step is the last step the user needs to complete. |
isTestForm | () => boolean | Returns True when the current form is in test mode (and not live). |
updateUserId | (userId: string, merge?: boolean) => void | |
setCalendlyUrl | (url: string) => void | If a Calendly scheduling flow is embedded in your form, you can dynamically update the calendar by calling this function and passing in a new Calendly URL. |
cart | If the Stripe connector is configured and connected, then the purchase cart is available with a number of properties about the cart and items within it. See here for details. | |
products | If the Stripe connector is configured and connected, then the purchasable products are available as a hash. See here for details. |
Last modified 8d ago