Apparently from documentation, you can use public func values(includeHidden includeHidden: Bool = false) -> [String: Any?] to get form value. But how? ( please I'm a beginner)
my code is like:
class HomeViewController : FormViewController {
override func viewDidLoad() {
super.viewDidLoad()
form +++ DateInlineRow() {
$0.title = "start"
$0.value = NSDate()
}
<<< DateInlineRow() {
$0.title = "end"
$0.value = NSDate()
}
<<< PushRow<String>() {
$0.title = "Type"
$0.options = ["all", "1", "2", "3", "4"]
$0.value = "all"
$0.selectorTitle = "Type:"
}
<<< ButtonRow("Button\(index)") { $0.title = "search: " }
}
}
Where in the code should I write values(false) to get form data?
Question 2 : I want to do a search from database with values from above form as condition, and then present data in a new TableView, how do I do the presentation work with Eureka?
I am interested too. Also I want to know how do I get the location coordinates, after choosing a spot on the map.
Thanks.
The following will give you a dictionary of form values where the key is equal to the tag for each form item.
let formvalues = self.form.values()
let some_answer = formvalues["somekey"]
FormViewController has a form property that represents the form DSL. In order to get the form values, as you said we should invoke form.formValues(). Take into account that only rows that have an associated tag are included in the result dictionary, row tag is the key and row value is its value.
A row tag is like the row id, it should be unique among all form rows. Each row has a property
tagofStringtype, there is also a row initializer that receive the tag as a parameterpublic init(_ tag: String? = nil, @noescape _ initializer: (Self -> ()) = { _ in }).
In regards to question 2, FormViewController extends UIViewController and it's up to you to make the presentation either programmatically or using segues. Only relevant thing here is to handle a button row tap/select event or whatever you want to use to trigger the search.
@plastus @mtnbarreto How do you update formValues automatically when data in one row is changed?
Most helpful comment
The following will give you a dictionary of form values where the key is equal to the tag for each form item.