Form

A form interface that provides form state management and submission handling.

This interface represents a form with type-safe data binding and validation capabilities. It manages form state, field validation, and form submission logic.

Usage:

val form = rememberForm(
initialValue = FormData(),
onSubmit = { data -> /* handle submission */}
)

Parameters

T

The type of the form data.

Properties

Link copied to clipboard
abstract val binding: FormBinding<T>

The form binding that provides access to form operations.

Link copied to clipboard
abstract val meta: FormMeta

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

Link copied to clipboard
abstract val value: T

The current data value of the form.

Functions

Link copied to clipboard
fun <T, V> Form<T>.Field(selector: (T) -> V, updater: T.(V) -> T, validator: FieldValidator<V>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true, render: @Composable (FormField<V>) -> Unit)

Creates a form field with validation and state management.

fun <T, V, S, U> Form<T>.Field(selector: (T) -> V, updater: T.(V) -> T, adapter: FieldTypeAdapter<V, S, U>, validator: FieldValidator<S>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true, render: @Composable (FormField<U>) -> Unit)

Creates a form field with type adaptation, validation, and state management.

fun Form<TextFieldState>.Field(validator: FieldValidator<CharSequence>? = null, name: FieldName? = null, enabled: Boolean = true, render: @Composable (FormTextField) -> Unit)

Creates a field for a TextFieldState-based form with direct text validation.

fun <S> Form<TextFieldState>.Field(adapter: TextFieldStateAdapter<S>, validator: FieldValidator<S>? = null, name: FieldName? = null, enabled: Boolean = true, render: @Composable (FormTextField) -> Unit)

Creates a field for a TextFieldState-based form with type adaptation and validation.

fun <T> Form<T>.Field(selector: (T) -> TextFieldState, validator: FieldValidator<CharSequence>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true, render: @Composable (FormTextField) -> Unit)

Creates a form text field with validation and state management for TextFieldState.

fun <T, S> Form<T>.Field(selector: (T) -> TextFieldState, adapter: TextFieldStateAdapter<S>, validator: FieldValidator<S>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true, render: @Composable (FormTextField) -> Unit)

Creates a form text field with type adaptation, validation, and state management.

Link copied to clipboard
abstract fun handleSubmit()

Handles form submission by validating all fields and calling the submit callback if validation passes.

Link copied to clipboard
fun <T, V> Form<T>.rememberField(selector: (T) -> V, updater: T.(V) -> T, validator: FieldValidator<V>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true): FormField<V>

Creates and remembers a form field control with validation and state management.

fun <T, V, S, U> Form<T>.rememberField(selector: (T) -> V, updater: T.(V) -> T, adapter: FieldTypeAdapter<V, S, U>, validator: FieldValidator<S>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true): FormField<U>

Creates and remembers a form field control with type adaptation, validation, and state management.

fun <T> Form<T>.rememberField(selector: (T) -> TextFieldState, validator: FieldValidator<CharSequence>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true): FormTextField

Creates and remembers a form text field control with validation and state management.

fun <T, S> Form<T>.rememberField(selector: (T) -> TextFieldState, adapter: TextFieldStateAdapter<S>, validator: FieldValidator<S>? = null, name: FieldName? = null, dependsOn: FieldNames? = null, enabled: Boolean = true): FormTextField

Creates and remembers a form text field control with type adaptation, validation, and state management.

Link copied to clipboard
fun <T, R> Form<T>.watch(calculation: FormData<T>.() -> R): R

Watches for changes in form state and recomputes a derived value.