I made a form with Eureka and was wondering how to hide a row or section depending if it contains a value or not:
form
+++ Section("Car")
<<< TextRow() {
$0.title = car?.name
}
+++ Section("Car color")
<<< TextRow() {
$0.title = car?.color
}
+++ Section("Car description")
<<< TextRow() {
$0.title = car?.description
$0.cell.textLabel?.numberOfLines = 0
}
+++ Section("Car brand")
<<< TextRow() {
$0.title = car?.brandName
}
+++ Section("Comment")
<<< TextRow() {
$0.tag = "Comment"
$0.title = car?.internComment
$0.cell.textLabel?.numberOfLines = 0
$0.hidden = Condition.function([])
{ form in
if (form.rowBy(tag: "Comment") as? TextRow) != nil {
return false
}
return true
}
}
I tried it with
$0.hidden = Condition.function([])
{ form in
if (form.rowBy(tag: "Comment") as? TextRow) != nil {
return false
}
return true
}
but it is hiding it regardless if it contains a value or not.
You are checking for the row itself, check for its value
$0.hidden = Condition.function([]) { form in
if (form.rowBy(tag: "Comment") as? TextRow)?.value != nil {
return false
}
return true
}
or shorter
$0.hidden = Condition.function([]) { form in
return !((form.rowBy(tag: "Comment") as? TextRow)?.value ?? false)
}