gform.state

Introduction

The gform.state object in Gravity Forms is a utility for managing form state, including storing data, registering callbacks, and observing state changes.

Overview

MethodParametersReturnsDescription
callbacksNoneObjectStores callback functions for state changes, keyed by form or field IDs (e.g., {678: Array(1)}).
dataNoneObjectStores state data for forms or fields, keyed by IDs (e.g., {678: Array(0)}).
get()Object|StringAnyRetrieves the state value for a specified form or field.
set()Object|String|AnyUndefinedUpdates the state value for a specified form or field.
watch()Object|String|FunctionUndefinedRegisters a callback to observe state changes for a form or field.