Hi,
Is there a way to implement 2 level PushRow?
For example I would like to view countries in the first level and whenever you select the country, the second level will presented with cities.
Any idea?
Thanks
I'm in the middle of something like this myself.
The PushRow selectorViewController itself is a form, so you could try something like:
<<< PushRow<String>(yourFirstTag) {
$0.title = $0.tag
$0.options = yourFirstOptions
$0.selectorTitle = "Your First Title"
$0.value = yourFirstDefaultValue
$0.onPresent({ (formViewController, selectorViewController) in
selectorViewController.form.first! <<< PushRow<String>(yourSecondTag) {
$0.title = $0.tag
$0.options = yourSecondOptions
$0.selectorTitle = "Your Second Options"
$0.value = yourSecondDefaultValue
}
})
}
Thank you, I will give it a try
The only issue with the code above is if you have no options set for the first level PushRow. In that case, you might try something like this in the .onPresent:
guard let first = selectorViewController.form.first else { return }
guard let firstSection = first as Section else { return }
for firstLevel in firstLevelData {
let newRow = ListCheckRow<String>(firstLevel) { newRow in
newRow.title = newRow.tag
newRow.options = yourSecondLevelOptions
newRow.selectorTitle = newRow.tag
newRow.value = yourSecondDefaultValue
}
firstSection.append(newRow)
}
As I understand it from looking at how Eureka builds a form, this is pretty much how forms are made already. I'm sure Xmartlabs are looking into building nested forms so hopefully this will be available in the future.
To stay Eureka-y, instead of firstSection.append(newRow), this might work:
firstSection <<< newRow
@zajil I think we can close this issue, right?
Most helpful comment
I'm in the middle of something like this myself.
The PushRow selectorViewController itself is a form, so you could try something like: