moonvader
moonvader

Reputation: 21111

Clear Eureka form

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

Answers (3)

C. Moulinet
C. Moulinet

Reputation: 204

Here is the function I use to clear my form

   for row in form.allRows {
        row.baseValue = nil
    }
    tableView.reloadData()

Upvotes: 2

Vladimir
Vladimir

Reputation: 1053

You can use replaceAll() from RangeReplaceableCollection protocol

form.removeAll()

Upvotes: 1

Taylor Simpson
Taylor Simpson

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

Related Questions