Hi,
thanks for this nice library.
I found a bug. When I generate text field from ui schema which expects string type, and i write number inside, it will not pass (with error text that it must be string).
This is wrong since my text field should be a telephone number "+420777666555", but with the casting it is changed to 420777666555, and this does not satisfy my schema.
The bug is in file com.copperleaf.forms.compose.widgets.material.textFieldWidget.kt
See below where i commented the line with the bug.
val updatableText = rememberUpdatableText<T>(
initialValue = currentValue,
mapStateToText = mapStateToText,
onTextChange = { value ->
// send the value as a well-formed T value, if possible. Otherwise, still send the data to the ViewModel,
// but as a string
// updateFormState(value.toIntOrNull() ?: value) //BUG StringControl.control() should not use this
updateFormState(value) // correction
}
)
The StringControl.control() below uses the code above, but we want String, so it should not be cast to Int.
public fun StringControl.control(): Registered<UiElement.Control, ControlRenderer> = uiControl {
textFieldWidget(
defaultValue = "",
mapper = { it.jsonPrimitive.content },
mapStateToText = { it },
)
}
Hi,
thanks for this nice library.
I found a bug. When I generate text field from ui schema which expects
stringtype, and i write number inside, it will not pass (with error text that it must be string).This is wrong since my text field should be a telephone number "+420777666555", but with the casting it is changed to 420777666555, and this does not satisfy my schema.
The bug is in file com.copperleaf.forms.compose.widgets.material.textFieldWidget.kt
See below where i commented the line with the bug.
The StringControl.control() below uses the code above, but we want String, so it should not be cast to Int.