Search code examples
iosswiftswift3eureka-forms

How to clear a value from an inline row, such as DateInlineRow?


If I use the DateInlineRow or any other inline row, there is no way to clear the value. How can this be done?


Solution

  • I had been working in your question, I will use DateInlineRow as example

    if you want to clear the value

       <<< DateInlineRow(){
            $0.tag = "inlineDateTime"
            }.cellSetup({ (dateCell, dateTimeRow) in
            // Setup the start date
            let currentDate = NSDate() as Date
            dateTimeRow.dateFormatter?.dateStyle = .short
            dateTimeRow.dateFormatter?.timeStyle = .short
            dateTimeRow.value = currentDate
            dateCell.textLabel?.text = "" //if you want clear the value in creation
        }).onCellSelection({ (cell, row) in
            row.cell.textLabel?.text = "" //if you want clear the value in cell selection
        }).onChange({ (row) in
            row.cell.textLabel?.text = "" //if you want clear the value on value change
        })
    

    If you want to clear the value in some other button

    Search by tag and set the value of the row to nil

    if let dateTimeInlineRow = self.form.rowBy(tag: "inlineDateTime") as? DateInlineRow
                        {
                            if let baseCellText = dateTimeInlineRow.baseCell as? Cell<Date>
                            {
                                baseCellText.row.value = nil
                                baseCellText.update()
                            }
                        }