ControlState

data class ControlState<T>(val value: MutableState<T?> = mutableStateOf(null), val initValue: MutableState<T?> = mutableStateOf(null), val displayText: MutableState<String?> = mutableStateOf(null), val labelOverride: MutableState<String?> = mutableStateOf(null))

Reactive state of a single form control.

Holds everything about the control's state needed for rendering, validation and change tracking, using the Compose State API for automatic recomposition.

Parameters

value

Current value of the control (edited by the user) - MutableState.

initValue

Original value loaded from the database or set as a default - MutableState.

displayText

Text shown to the user when it cannot be derived from value on every render: the edit buffer of a number field (1. is not a number yet) or the label of the selected dropdown item (needs a query). null means "not determined" - the control fills it in itself, synchronously or with a query. That is why updateControl from outside clears this field: writing the value invalidates the text, and the clearing itself is the signal to work it out again.

labelOverride

Label overridden from an action, in place of the one from the schema.

Type Parameters

T

Type of the data held by the control.

Constructors

Link copied to clipboard
constructor(value: MutableState<T?> = mutableStateOf(null), initValue: MutableState<T?> = mutableStateOf(null), displayText: MutableState<String?> = mutableStateOf(null), labelOverride: MutableState<String?> = mutableStateOf(null))

Properties

Link copied to clipboard
val displayText: MutableState<String?>
Link copied to clipboard
val initValue: MutableState<T?>
Link copied to clipboard
val labelOverride: MutableState<String?>
Link copied to clipboard
val value: MutableState<T?>