Reputation: 21111
I am using Eureka form in my iOS app. I want to clear / reload form by pressing the button. How it should be done?
I tried this code with no luck
for row in self!.form.allRows {
row.reload()
row.updateCell()
}
self!.tableView.reloadData()
I know that there is way to provide default values for all fields but I don't want to specify all fields values - just want to find universal way to refresh / clean form.
Upvotes: 4
Views: 2095
Reputation: 204
Here is the function I use to clear my form
for row in form.allRows {
row.baseValue = nil
}
tableView.reloadData()
Upvotes: 2
Reputation: 1053
You can use replaceAll() from RangeReplaceableCollection protocol
form.removeAll()
Upvotes: 1
Reputation: 970
Have you tried getting an array of all the values of the forms and then looping through it setting their value to nil and then updating the cells or using tableView.reload?
In fact you can grab them by tag or in a dictionary:
// Get the value of a single row
let row: TextRow? = form.rowBy(tag: "MyRowTag")
let value = row.value
// Get the value of all rows which have a Tag assigned
// The dictionary contains the 'rowTag':value pairs.
let valuesDictionary = form.values()
Upvotes: 1