MappedEnum does not keep the order of corresponding Enumeration
There seems to be a regression since May 15, 2011 when MappedEnum's buildDisplayList() was updated from
to
with commit description 'Fix deprecation for 2.9 compliance'.
Unfortunately, values.map does not keep the original order of items in enum, and thus rendering MappedEnum via toForm() (which uses buildDisplayList) will result in a select (drop down control) where items are not ordered like they are ordered in original Enumeration.
Simple fixes could be:
or
Original thread referencing the commit, related discussion in scala-user list, and example fixes given above:
https://groups.google.com/d/topic/liftweb/DmEof5Zr1v8/discussion
enum.map(a => (a.id, a.toString)).toList
to
enum.values.map(a => (a.id, a.toString)).toList
with commit description 'Fix deprecation for 2.9 compliance'.
Unfortunately, values.map does not keep the original order of items in enum, and thus rendering MappedEnum via toForm() (which uses buildDisplayList) will result in a select (drop down control) where items are not ordered like they are ordered in original Enumeration.
Simple fixes could be:
enum.values.toSeq.map(a => (a.id, a.toString)).toList
or
enum.values.toList.map(a => (a.id, a.toString))
Original thread referencing the commit, related discussion in scala-user list, and example fixes given above:
https://groups.google.com/d/topic/liftweb/DmEof5Zr1v8/discussion
Leave a comment
(In revision:4d3ccdc44b0b8d70883ca3fd6781ac9af54813d4) Preserve Enumeration ordering when building display list in MappedEnum. Closes #1142
Branch: master
Branch: master
on 2011-11-04 10:41 *
By jeppenejsum
(In revision:88f3b29766937d66eeee7c2234234d27a1a6223d) Preserve Enumeration ordering when building display list in MappedEnum. Closes #1142
Branch: master
Branch: master