FormState

class FormState<T>(value: T, val meta: FormMetaState) : FormData<T>

A mutable implementation of FormData that manages form state.

This class provides a concrete implementation of form state management with support for state persistence, validation, and metadata tracking. It integrates with Compose state to provide reactive updates when form data changes.

Usage:

val formState = FormState(
value = UserData(name = "", email = ""),
policy = FormPolicy()
)

Parameters

T

The type of the form data.

Constructors

Link copied to clipboard
constructor(value: T, policy: FormPolicy = FormPolicy())

Creates a new FormState with the specified value and policy.

constructor(value: T, meta: FormMetaState)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val meta: FormMetaState

The metadata associated with the form, including field states and submission status.

Link copied to clipboard
open override var value: T

The current data value of the form.

Functions

Link copied to clipboard
inline fun reset(newValue: T)

Resets the form to a new value and clears all field metadata.

Link copied to clipboard
inline fun setError(vararg pairs: Pair<FieldName, FieldError>)

Sets validation errors for specific fields.

Link copied to clipboard
open override fun toString(): String