punkhead
punkhead

Reputation: 36

Getting value true/false from checkbox on Eureka after submitting form via button

I am trying to pull all values from a form into Realm upon hitting a button. I've figured out how to pull the text value, as so:

<<< TextRow(){ row in
                row.title = "Referrals Out"
                row.placeholder = "4"
                row.onCellHighlightChanged({ (cell, row) in
                    if row.isHighlighted == false {
                        self.planTitle = row.value ?? ""
                        print(self.planTitle)
                    }
                }).cellSetup() {cell, row in
                    cell.titleLabel?.font = UIFont(name:"Noto Sans Kannada", size:15)
                }
            }

I am trying same, and have tried anything I could think of, including tag = title, but cannot get the value of the checkbox as a bool - true/false. Here is what I have for the checkbox:

<<< CheckRow(){ row in
            row.title = row.tag
            row.title = "Referrals Out"
            row.value = false
            row.onCellHighlightChanged({ (cell, row) in
                if row.isHighlighted == false {
                    self.referralsOut = row.value ?? false
                }
            })
        }

The button is working well to pull the text value, but cannot get the checkbox value. When I add in print(value) for the checkbox, it will print the value on page load, but not after I change the value of the checkmark to true or false, etc.

Any help greatly appreciate!!!

Upvotes: 1

Views: 194

Answers (1)

vadian
vadian

Reputation: 285220

To get the value after I change there is the .onChange modifier

<<< CheckRow(){ row in
    row.title = row.tag
    row.title = "Referrals Out"
    row.value = false
    row.onCellHighlightChanged({ (cell, row) in
        if row.isHighlighted == false {
            self.referralsOut = row.value ?? false
        }
    }).onChange { row in
        print(row.value!)
    }
}

Upvotes: 1

Related Questions