I am doing an app with Eureka form, and the problem is that I don't know how to get the value of the first textField.
The problem is that I should get the value of the first section DecimalRow and I should multiply it with the textField of the second section KalkulationCell (that is a custom cell) and I don't know how to merge these parts.
import UIKit
import Eureka
class ViewController: FormViewController {
override func viewDidLoad() {
super.viewDidLoad()
//var rules = RuleSet<String>()
form +++ Section("EINGABESUMME BRUTTO (EXXL MWST)")
{$0.header?.height = { 20 }}
<<< DecimalRow(){
$0.title = " "
//$0.value = 54
$0.tag = "MyRowTag"
}
.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)
}
let row: DecimalRow? = form.rowBy(tag: "MyRowTag")
let value = row?.value
// Get the value of all rows which have a Tag assigned
// The dictionary contains the 'rowTag':value pairs.
let valuesDictionary = form.values()
print(valuesDictionary)
form +++ Section("ZIEL-DB PROJEKT BRUTTO")
{
$0.header?.height = { 20 }
}
<<< KalkulationRow {
row in
row.cell.valueField.text = "54.00"
row.tag="hello"
}
form +++ Section("RABATT")
{
$0.header?.height = { 20 }
}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}
form +++ Section("SKONTO")
{
$0.header?.height = { 20 }
}
<<< IntRow(){
$0.title = "Tage:"
$0.placeholder = "2"
$0.add(rule: RuleRequired())
}
.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)
}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}
form +++ Section("DIVERSE ABZUGE")
{
$0.header?.height = { 20 }
}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}
form +++ Section("EINGABESSUME NETTO")
{
$0.header?.height = { 20 }
}
<<< DecimalRow(){
$0.title = " "
$0.value = 54.00
$0.placeholderColor = UIColor.green
}
.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)
cell.textField?.textColor = UIColor.green
cell.textField?.isUserInteractionEnabled = false
}
form +++ Section("ZIEL-DB PROJEKT NETTO")
{
$0.header?.height = { 20 }
}
<<< KalkulationRow { row in
row.cell.valueField.text = "54.00"
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
As vadian suggested You can detect text change with onChange
method as shown below:
.onChange({ decimal in
print(decimal)
})
And final code will be:
{
$0.header?.height = { 20 }
}
<<< DecimalRow(){
$0.title = " "
$0.tag = "MyRowTag"
}
.onChange({ decimal in
print(decimal)
})
.cellUpdate { cell, row in
cell.textField?.font = .boldSystemFont(ofSize: 18.0)
}