如何使用 Eureka 表单从更改文本字段的行中检索值?

How to retrieve value from a row with changed textfield with Eureka form?

我正在尝试检索 Eureka 表单行中键入字段的值 (https://eurekacommunity.github.io)。我已经设置了一个带有掩码的新文本字段,但是当我将它发回时 returns 我是空的。

文本行:

<<< TextRow(Constants.CPF) {
        [=10=].title = Constants.cpf_title
        [=10=].placeholder = Constants.cpf_placeholder
    }
    .cellSetup { cell, _ in
        let tf = JMMaskTextField(frame: cell.textField.frame)
        tf.maskString = "000.000.000-00"
        cell.textField.removeFromSuperview()
        tf.translatesAutoresizingMaskIntoConstraints = false
        cell.textField = tf
        cell.contentView.addSubview(tf)
    }
    .cellUpdate { cell, _ in
        cell.textField.delegate = self
    }

结果:

let values = self.form.values()
print(values[Constants.CPF])

Optional(nil)

显然面具工作正常,但我想我忘记设置一些东西。有人有什么想法吗?

如果你想在你的行中使用不同的 UITextField,你应该 create custom row。在这种情况下,您可以从 TextRow 继承并使用 JMMaskTextField 实现您的单元格。只需删除默认 textField 并设置新的(如您所做的)不起作用。