Probably not, empty values from all kvision form c...
# kvision
r
Probably not, empty values from all kvision form controls are always converted to
null
.
t
What is the reason for it? It forces me to give up implicit null safe checks and define all bind properties nullable.
r
For consistency, all form controls with different types (string, number, date) return null when no value is provided. I think it would be misleading to use empty strings instead of null for one type only.
What is your use case?
Do you use
FormPanel<T>
or just simple, standalone form control?
t
FormPanel
r
So I understand you would like to use as your model a data class with
val field: String = ""
instead of
val field: String? = null
?
t
exactly
r
I will experiment a bit and let you know if it could be fixed somehow
It seems the cause of your problem is another bug (?) in
decodeFromDynamic
. I've managed to fix form default values by replacing this function with
decodeFromString(kotlin.js.JSON.stringify(nativeObj))
.
I don't trust
decodeFromDynamic
anymore 🙂 I'll remove it from
RestClient
as well in the next release.
After fixing the issue you will be able to use any nullable or not nullable fields in the forms model, as long as there are any default values (even not empty like
0
,
"-"
,
Date()
) in the data class.
t
I was debuging decodeFromDynamic the other day, the problem is that the function treat null as object, because in JS
typeOf(null)
is
"object"
r
Probably you should fill an issue to kotlinx.serialization with the details
anyway, I'll remove it from KVision code
t
I am going to, I just want to investigate it a bit and write test for it.
👍 1