rememberFieldControl

fun <V> rememberFieldControl(name: FieldName, select: T.() -> V, update: T.(V) -> T, enabled: T.() -> Boolean = { true }, dependsOn: Set<FieldName>? = null, validate: T.() -> FieldErrors?? = null): FieldControl<V>

Remembers a field control for the given field name.

Usage:

rememberFieldControl(
name = "First name",
select = { firstName },
update = { copy(firstName = it) }
) {
if (firstName.isNotBlank()) {
noErrors
} else {
fieldError("must be not blank")
}
}

Return

The remembered field control.

Parameters

V

The type of the field value.

name

The name of the field.

select

The function to select the field value.

update

The function to update the field value.

enabled

The function to determine if the field is enabled.

dependsOn

The set of field names that this field depends on.

validate

The function to validate the field value.