I have use Eureka for my form but i am facing an issues. I setup the form using these code
form +++ Section("Add Event")
<<< TextRow("Event"){ row in
row.title = "Event"
row.placeholder = "Enter Event Name Here"
}
<<< DateRow("Date"){
$0.title = "Date"
$0.value = selectedDate
}
<<< TimeRow("Time"){
$0.title = "Time"
$0.value = selectedDate
}
let locationSearchTable = storyboard!.instantiateViewController(withIdentifier: "eventLocation") as! EventLocationViewController
form +++ Section("Location")
<<< CustomPushRow<EventLocationViewController>(){
$0.title = "Location"
$0.presentationMode = .segueName(segueName: "eventLocation" ,controllerProvider: locationSearchTable, onDismiss: nil)
}
here the custom push row class
public final class CustomPushRow<T: Equatable>: SelectorRow<PushSelectorCell<T>, SelectorViewController<T>>, RowType {
public required init(tag: String?) {
super.init(tag: tag)
presentationMode = .show(controllerProvider: ControllerProvider.callback {
return SelectorViewController<T>(){ _ in }
}, onDismiss: { vc in
print("On Dimiss")
_ = vc.navigationController?.popViewController(animated: true)
})
}
}
and when i wanna change the value of the form i use this method to change
let eventName : TextRow? = form.rowBy(tag:"Event")
eventName?.value = "asdasadsds"
but when i wanna change the custom push row i am having this issues cannot convert value of type 'BaseRow?' to specified type 'CustomPushRow?' when i do this
let row : CustomPushRow? = form.rowBy(tag: "Location")
How can i change the value of the CustomPushRow
Try taking your info a different way (a tip I got from Swift: How to get form values using Eureka form builder? helped me with another "cannot convert value of...." issue)
To READ the value on a row that gives you the error message:
Be sure to set tags on all your elements ($0.tag = "whatever")
instead of
let row : CustomPushRow? = form.rowBy(tag: "Location")
use
let dict = self.form.values(includeHidden: true)
Then you can see the value with something like
print(dict["whatever"])
Now, the other part of your question asked about SETTING the value, which is a different thing in Eureka.
From the docs (https://github.com/xmartlabs/Eureka#how-to-set-the-form-values-using-a-dictionary):
How to set the form values using a dictionary
Invoking setValues(values: [String: Any?]) which is exposed by Form class.
For example:
form.setValues(["IntRowTag": 8, "TextRowTag": "Hello world!", "PushRowTag": Company(name:"Xmartlabs")])
Where "IntRowTag", "TextRowTag", "PushRowTag" are row tags (each one uniquely identifies a row) and 8, "Hello world!", Company(name:"Xmartlabs") are the corresponding row value to assign.