2013-09-29 19 views
-1
val registrationForm: Form[Registration]=Form(
mapping(
"fname"->text(minLength=2), 
"lname"->text(minLength=1), 
"userEmail"->text(minLength=5), 
"userPassword" -> tuple(
    "main" -> text(minLength = 6), 
    "confirm" -> text 
).verifying(
    // Add an additional constraint: both passwords must match 
    "Passwords don't match", userPassword => userPassword._1 == userPassword._2 
), 
"gender"->number, 
"year"->number, 
"month"->number, 
"day"->number 
) 
{ 
// Binding: Create a User from the mapping result (ignore the second password and the 
accept field) 
(fname, lname, userEmail, userPassword, gender, year, month, day, _) => 
Registration(fname,lname,userEmail,userPassword._1, gender, year,month,day)//error here 
} 
{ 
    // Unbinding: Create the mapping values from an existing User value 
user => Some(user.fname, user.lname, user.userEmail,(user.userPassword, ""), 
user.gender, user.year, user.month, user.day, false) 
} 

)//end registrationForm 

我的情況下類是 -錯誤映射的形式的情況下類中發揮2階

case class Registration(fname:String, lname:String, userEmail:String, 
userPassword:String, gender:Int, year:Int,month:Int, day:Int) 

上面的代碼是給無差錯錯號的參數;預計= 8。我已經給在發生錯誤

+0

等待回覆 –

+0

這是一個重複的,來自同一個用戶。 –

回答

0

apply函數的參數列表中的行註釋太大:

(fname, lname, userEmail, userPassword, gender, year, month, day, _) 

它應該是8表單包含8個元素:

(fname, lname, userEmail, userPassword, gender, year, month, day) 
+0

不是這樣工作的 –