New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validation support to SplitRow #37
Comments
@kmav seems like there's indeed a connection missing - validation requests are not passed through SplitRow at all atm. If I understand you correctly, you'd like to call Unfortunately I do not have a lot of spare time currently, but I'm happy to merge a Pull Request if you want to give it a try. There is already a request hanging - so you might want to join forces with @GaDaXaRa to get that validation stuff finally done and merged: Since I do not have any such validation requirements, its kinda hard for me to judge if the solution is "correct" - in the sense of generally usefull for others as well. |
Thank you all of you for taking attention to this. From my comment above (1) it results that left row validation propagates up to SplitRow when I type text and then delete it to have empty string. In that case, a new row pop ups below with the validation alert string "This field is required". Do you mean that the SplitRow validation is not fully implemented yet? |
@kmav exactly. Validation is not integrated in SplitRow, since the original approach was to leave it up to the child rows. This also means there is no validation request passing through SplitRow coming from the form. I can see how this leads to inconsistent behavior which in turn leads to confusion. However, I‘m not really familiar with the validation possibilities in Eureka and don‘t have any spare time right now to wrap my head around. Feel free to give it a try if you like, I‘m happily merge a PR. |
The Validation should work like this: if the Cells that are in the SplitRow are both valid, then the SplitRow should return valid. |
Fixed by #48. |
Hello.
Thank you for the very useful SplitRow extension.
How I can validate text content (required) of left TextRow?
I added validation logic on rowLeft (TextRow) : row.onRowValidationChanged(self.validateNoteButtonRow)
func validateNoteButtonRow(_ cell: TextCell, _ row: TextRow) {
if let noteRow = self.form.rowBy(tag: "addNote") as? SplitRow<TextRow,ButtonRow> {
let rowIndex = noteRow.indexPath!.row
while noteRow.section!.count > rowIndex + 1 && noteRow.section?[rowIndex + 1] is LabelRow {
noteRow.section?.remove(at: rowIndex + 1)
}
if !row.isValid {
for (index, validationMsg) in row.validationErrors.map({ $0.msg }).enumerated() {
let labelRow = LabelRow() {
$0.title = validationMsg
$0.cell.height = { 30 }
$0.cell.backgroundColor = .red
$0.cell.textLabel?.tintColor = .white
}
let indexPath = noteRow.indexPath!.row + index + 1
noteRow.section?.insert(labelRow, at: indexPath)
}
}
} else {
Log.debug("Validation: SplitRow nil")
}
}
I would like:
to do it as the Eureka example that pop ups a label with message below of the SplitRow: I succeeded with that using your hints from another issue. The validation is activated when starting to type text.
To make the above validation to execute when I call self.form.validate() because the user can press an ADD button to add what is in TextRow on a list. When the user press ADD, I would like to force validation. For the moment, when I call self.form.validate() only validations created in other basic fields of the form are called. Maybe SplitRow validation is not called because it is included/defined only in let TextRow? Another thing that I tried was to force call validation code but it did not work... Code below did not succeeded to call validation of TextRow field:
// if let noteRow = self.form.rowBy(tag: "addNote") as? SplitRow<TextRow,ButtonRow>, let row = noteRow.rowLeft as TextRow? {
// Log.debug("VitalSignsViewController: checkIsEmpty: note field/row found")
// self.validateNoteButtonRow(row.cell, row)
// }
Thank you very much in advance :)
The text was updated successfully, but these errors were encountered: