I am having a bit of trouble with a part of the Eureka framework for Swift in iOS. It works fine, except for when I try to clear out a form programatically which is already on the screen all the fields seem to clear out fine, except for the DecimalRow type field.
(form.rowBy(tag: "name") as? TextRow)?.value = ""
**(form.rowBy(tag: "amount") as? DecimalRow)?.value = Double(0.0)**
(form.rowBy(tag: "date") as? DateRow)?.value = Date()
(form.rowBy(tag: "reimb") as? SwitchRow)?.value = false
The DecimalRow type field stays whatever value was in it and does not respond to the line above in bold (asterisk-ed).
Any insight appreciated. Many thanks.
Have you reloaded the row?
This worked fine on my code.
(self.form.rowBy(tag: "user_weight") as? DecimalRow)?.value = Double(0.0)
(self.form.rowBy(tag: "user_weight")?.reload()
Where
<<< DecimalRow("user_weight")
And if I run
self.form.values()
I get:
"user_weight": Optional(0.0)
So its cleared
You can also clear the form in this way
self.form.setValues(["user_weight": 0])
An example made by them
form.setValues(["IntRowTag": 8, "TextRowTag": "Hello world!", "PushRowTag": Company(name:"Xmartlabs")])
https://github.com/xmartlabs/Eureka#how-to-set-the-form-values-using-a-dictionary