Before submitting issues ...
When submitting issues, please provide the following information to help maintainers to fix the problem faster:
i'm trying to set the value based to name in a realm object however it keep showing Ladder { as text in cell instead of the name. here is my code
<<< MultipleSelectorRow<Ladder>("Rank") {
$0.hidden = Condition.predicate(NSPredicate(format: "$Game == nil"))
$0.title = $0.tag
}.cellUpdate { cell, row in
let formvalues = self.form.values()
let game = formvalues["Game"] as! Game
let ranks = Array(game.ranks)
row.options = ranks
row.displayValueFor = { (rowValue: Set<Ladder>?) in
return rowValue?.map({ $0.name }).sorted().joined(separator: ", ")
}
cell.textLabel?.font = UIFont(name: "Avenir-Book", size: 16)
cell.preservesSuperviewLayoutMargins = false
cell.separatorInset = UIEdgeInsets.zero
cell.layoutMargins = UIEdgeInsets.zero
}
realm model
class Ladder: Object {
dynamic var id = ""
dynamic var name = ""
override static func primaryKey() -> String? {
return "id"
}
}
First of all, displayValueFor should be defined in the row initializer and not in cellUpdate as it does not change, right?
That might fix your issue.
i've put in cellUpdate since the value change depending on another rows value.
What I see in your code is that the options might change but the type of the value should not change. Also you are not using anything specific to another row in your displayValueFor code.
Anyway, alternatively you can make Ladder conform to CustomStringConvertible and return its name as description.
i've tried that however this will only return the description in the formValues where i need id in the ladder model to pass to the server.
It will not only return the description but the value itself. But if you print formValues then Xcode will print the description for the Ladder object
Yes i know it will, but what i want is it to print the object itself in formValues, so i can access other values in the object like the primary key, in order to pass something to the server.
row.value type is Ladder, from there you can map the value and get either the id or the name.
Most helpful comment
What I see in your code is that the options might change but the type of the value should not change. Also you are not using anything specific to another row in your
displayValueForcode.Anyway, alternatively you can make
Ladderconform toCustomStringConvertibleand return its name as description.