Is it possible to scroll to the first form field that is invalid after calling validate on the form?
I just get an array of validationErrors but not a list of rows or cells I could work with?
I found a solution by myself but I am not sure if this is the best approach.
Basically I am validating the whole form so the field get marked as invalid
and than I validate each field again to get the first field that is invalid.
private func validateForm(form: Form) -> Bool {
form.validate()
for row in form.allRows.filter({ !$0.isHidden}) {
guard row.validate().isEmpty else {
row.baseCell.becomeFirstResponder()
row.select(animated: true, scrollPosition: .top)
return false
}
}
return true
}
Most helpful comment
I found a solution by myself but I am not sure if this is the best approach.
Basically I am validating the whole form so the field get marked as invalid
and than I validate each field again to get the first field that is invalid.