playframework/Play20 — pull request #240 by leon (2012-04-18 06:56:09+00:00)
Title: Enum mapper

Enum wrapper for form

In Models

```scala
object UserStatus extends Enumeration {
val Free = Value("free")
val Busy = Value("busy")

val options = values.map(a => (a.toString -> a.toString.capitalize))(collection.breakOut)
}

case class User(
status: UserStatus.Value = UserStatus.Free
)
```

In Controller

```scala
val userForm = Form(
mapping(
"status" -> enum(UserStatus)
)(User.apply)(User.unapply)
)
```

In View

```scala
@select(
userForm("status"),
UserStatus.options,
'_label -> "Status",
'_default -> "Choose Status",
'_showConstraints -> false
)
```