rememberForm
Remembers a form with the given initial value and submission handler.
This function creates and remembers a form instance that manages form state, validation, and submission. The form state is automatically saved and restored across configuration changes.
Usage:
val form = rememberForm(
initialValue = UserData(name = "", email = ""),
onSubmit = { userData ->
// Handle form submission
submitUserData(userData)
}
)
Return
A Form instance that manages the form state and submission.
Parameters
The type of the form data.
The initial value for the form.
The saver used to save and restore the form state across configuration changes.
The form policy that defines validation behavior and options.
The callback function called when the form is submitted successfully.
Remembers a form with the given form state and submission handler.
This overload allows you to provide your own form state instance, giving you more control over state management and persistence.
Usage:
val formState = rememberFormState(initialValue = UserData())
val form = rememberForm(
state = formState,
onSubmit = { userData ->
// Handle form submission
submitUserData(userData)
}
)
Return
A Form instance that manages the form state and submission.
Parameters
The type of the form data.
The form state to use for this form.
The callback function called when the form is submitted successfully.