Hi, is it possible to use form with data class and...
# kvision
t
Hi, is it possible to use form with data class and keep some properties, which are not editable (there is no matching field in form). For example:
Copy code
data class Comment(val title: String val note: String, author_id: Int)
And I the form contains only title and note, when I call
form,getData()
I get an error saying
author_id
is required.
In general our data classes rarely match the form fields exactly.
r
What value do you want to get for
author_id
? It would probably work if you have default value for it.
t
The value I passed in using form.setData()
In HTML form it would be hidden field, but actually I don need to render hidden field, just preserve the value.
r
The problem is the value passed with
setData
is not stored anywhere.
setData
just copies values for the items added to the form.
setData
is optional. You can only use
getData
and there must be a way to create an instance of the model class.
But perhaps it can be done ... there should be no problem storing the value and then just use it as a template to avoid deserialization error ...
Please fill an issue for this if you don't mind.