Form

class Form(scope: CoroutineScope)

A form is a list of FormFields with methods to manage them (add, remove, verify, etc).

Forms can be used for single text inputs like in a login form, or for more complex scenarios like image selection and upload to a service.

Parameters

scope

A coroutine scope, used for observing the form fields and updating the isComplete state.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope)

Properties

Link copied to clipboard
val isComplete: StateFlow<Boolean>

State flow that is true if all the form fields in this form are valid.

Functions

Link copied to clipboard
fun addFormField(formField: FormField<*>)
Link copied to clipboard
fun addFormFields(vararg formFields: FormField<*>)
fun addFormFields(formFields: List<FormField<*>>)

Add multiple form fields at once.

Link copied to clipboard
fun removeFormField(formField: FormField<*>)

Remove a form field.

Link copied to clipboard
fun removeFormFields(vararg formFields: FormField<*>)
fun removeFormFields(formFields: List<FormField<*>>)

Remove multiple form fields at once.

Link copied to clipboard

Use this function when you want to validate the entire form, for instance when the user clicks a submit button.