2012-05-26 31 views
2

新玩法,看起來像一個可以將數字約束應用於Ints和Longs,但不是雙精度。Play 2.0表單映射約束:Double不支持?

給定具有雙重屬性的案例類別的顯示停止符的種類不能被綁定/解除綁定;即

case class Foo(orderTotal: Double) 

// no dice, need a Double but get an Int (same deal with longNumber) 
val form = Form(mapping('orderTotal -> number)(Foo.apply)(Foo.unapply)) 

任何人都有解決方法嗎?看起來像是一個疏忽,不是?你會認爲Double是一個相當常見的需求...

+2

這是一個已知的限制2.0。這是固定在主。一個簡單的解決方法就是實現一個['Formatter [Double]'](http://www.playframework.org/documentation/api/2.0.1/scala/index.html#play.api.data.format.Formatter) –

+0

很酷,感謝Julian的解決方法。我幾天前克隆了github repo,併爲此而建造;這是一個非常新的加法? – virtualeyes

+0

它在[2012年4月]中添加(https://github.com/playframework/Play20/commit/652d39e50f6cc660437bc680e44b309d1c5ed840#framework/src/play/src/main/scala/play/api/data/format/Format.scala) –

回答

0

看到朱利安的評論上面,解決了2.1快照...