Eureka icon indicating copy to clipboard operation
Eureka copied to clipboard

Nested form - cells disappear

Open tallot13 opened this issue 4 years ago • 5 comments

Created custom row like pushRow with value type Eureka.Form for nested forms. for example created nested form with TextAreaRow after submission I change the value, go back and go to the form again, the edit field disappears, what could it be? disappears for various reasons if row.title is not set, or there was no value, but tap on the field, does anyone know how to get around this and why is this happening? the table cell itself has a height and a frame different from 0, but it is not in the hierarchy. isDisabled = false and isHidden = false

row class

final class FormRow: Row<FormContentCell>, PresenterRowType, RowType {

cell class

class FormContentCell: Cell<Form>, CellType {

use case nested

form +++ Section()
        <<< FormRow() {
            let form = Form()
            $0.title = "title"
            $0.value = form
            $0.displayValueFor = { (value) in
                return form.rowBy(tag: "title")?.baseValue as? String
            }
        }

nested form view controller

class NestedFormViewController: FormViewController, TypedRowControllerType {

public var row: RowOf<Form>!

var onDismissCallback: ((UIViewController) -> Void)?

required public init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
}

public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
    super.init(nibName: nil, bundle: nil)
}

convenience public init(_ callback: ((UIViewController) -> ())?){
    self.init(nibName: nil, bundle: nil)
    onDismissCallback = callback
}

override func viewDidLoad() {
    super.viewDidLoad()
    form = row.value!
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    row.baseCell.formViewController()?.tableView.reloadData()
    onDismissCallback?(self)
}

tallot13 avatar Oct 09 '20 09:10 tallot13

I have never tried nested forms. Are you not seeing any errors in the console?

mats-claassen avatar Oct 09 '20 11:10 mats-claassen

no errors.. tableview delegates called for every missed row and returned baseCell, if instead of baseCell return UITableViewCell(), then the cell will be empty, not missed

tallot13 avatar Oct 09 '20 12:10 tallot13

So are you overriding the Tableview delegate methodds from Eureka? You should not need to do that.

BTW: Instead of row.baseCell.formViewController()?.tableView.reloadData() just call tableView.reloadData()

EDIT: I am just realizing that you are reloading the other form so nevermind

mats-claassen avatar Oct 09 '20 14:10 mats-claassen

no, not overriding, breakpoint in source code of Eureka FormViewController, upper all code nested form view controller if added this bad code in NestedFormViewController, works fine or in viewDidLoad(). But how fix without this..

override func viewDidAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
        self.tableView.reloadData()
    }
}

tallot13 avatar Oct 09 '20 14:10 tallot13

or like this works too

override func viewDidLoad() {
    super.viewDidLoad()
    form = row.value!
    DispatchQueue.main.async {
        self.tableView.reloadData()
    }
}

tallot13 avatar Oct 09 '20 15:10 tallot13