ndchorley
01/02/2018, 4:29 PMdata class Session(val id: Int? = null, val date: LocalDate, val student: Student, val amount: Int)
and all the fields for this appear in the form, but I can't work out how to construct a lens to extract one of these.
Denton showed me how to create a lens to extract a data class from a single form field, e.g.
private val studentLens = FormField.map { Student(name = it) }.required("studentName")
private val studentFormBody = Body.webForm(Validator.Strict, studentLens).toLens()
but obviously having multiple fields is more complicated. I looked through the cookbook on the http4k website, but didn't see anything that helped. I looked at the BodyLens
class, but wasn't really sure if that's what one's supposed to use in that case (or how to use it, tbh).