Search code examples
eureka-forms

How to disable an ImageCheckRow


I've been struggling with this for a few days. I have a list of ImageCheckRow types and I want to mark them as checked or not checked and then disable them so the user can't change them. I have the following code executing:

                            let multi = subvalue.extractBool("multi", ifnil: false)
                            let disableEntry = subvalue.extractBool("disabled", ifnil: false)
                            let title: String! = subvalue.extractString("title", ifnil: "Select")
                            let defaultValues = subvalue.extractNSDictionary("values");

                            let imageChecked: String!
                            let imageUnchecked: String!

                            if (multi)! {
                                currentSection = SelectableSection<ImageCheckRow<String>>(title, selectionType: .multipleSelection)
                                imageChecked = "images/checkbox-checked"
                                imageUnchecked = "images/checkbox-unchecked"
                            } else {
                                currentSection = SelectableSection<ImageCheckRow<String>>(title, selectionType: .singleSelection(enableDeselection: true))

                                // We should change these to radios at some point
                                imageChecked = "images/radio-checked"
                                imageUnchecked = "images/radio-unchecked"
                            }
                            form +++ currentSection!

                            if let options = subvalue.extractArray("options") {
                                for option in options {
                                    for (optionKey, optionValue) in option as! NSDictionary {

                                        currentSection! <<< ImageCheckRow<String> { row in
                                            row.tag = "\(tagname)_\(optionKey)"
                                            row.title = optionValue as? String
                                            row.selectableValue = optionKey as? String

                                            if let dvkey = optionKey as? String {
                                                if let _ = defaultValues?.value(forKey: dvkey) {
                                                    row.value = optionKey as? String
                                                }
                                            }

                                            row.disabled = Condition(booleanLiteral: disableEntry!)
                                            row.evaluateDisabled()

                                        }.cellSetup { cell, _ in
                                            cell.trueImage = UIImage(named: imageChecked)!
                                            cell.falseImage = UIImage(named: imageUnchecked)!
                                        }
                                    }
                                }
                            }

When 'disableEntry' is true the ImageCheckRow is still valid for clicking and the image changes from checked to unchecked and vice-versa. How should I be disabling these rows?


Solution

  • Try pointing to the latest commit in master.

    It was an issue in Eureka that was solved after the release 3.0.0 was made. It was solved in PR #1063 https://github.com/xmartlabs/Eureka/pull/1063