Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework Leon Salat Model Form Mapping

I'm creating a scala application using Play framework and mongoDB. I manage to have the connections up using Leon Play-Salat. I have a model

case class Person(
  id: ObjectId = new ObjectId,
  fname: String,
  mname: String,
  lname: String
)

In my controller I need to map it to a form

val personForm: Form[Person] = Form(

// Defines a mapping that will handle Contact values
mapping(
  "id" -> of[ObjectId],
  "fname" -> nonEmptyText,
  "mname" -> text,
  "lname" -> nonEmptyText     
)(Person.apply)(Person.unapply))

How do I map the ObjectID to the form ? I'm getting error Object not found for the ObjectId.

like image 439
William Avatar asked Oct 15 '12 03:10

William


1 Answers

Manage to get it working

val personForm: Form[Person] = Form(
// Defines a mapping that will handle Contact values
mapping(
  "id" -> ignored(new ObjectId),
  "fname" -> nonEmptyText,
  "mname" -> text,
  "lname" -> nonEmptyText     
)(Person.apply)(Person.unapply))

I'm trying to do a CRUD function thus need the ID.

like image 197
William Avatar answered Sep 28 '22 00:09

William