开发者

How to set an empty value in a lift select element?

开发者 https://www.devze.com 2023-01-15 06:07 出处:网络
I am trying to set an empty value (as a first choice) in a lift select element: SHtml.select((\"\", \"\") :: (MyObject.findA开发者_如何学Goll(By(MyObject.creator, User.currentUser.open_!.id))), ...

I am trying to set an empty value (as a first choice) in a lift select element:

SHtml.select(("", "") :: (MyObject.findA开发者_如何学Goll(By(MyObject.creator, User.currentUser.open_!.id))), ...

However it gives me this error:

error: type mismatch;
found: List[(String, java.lang.Object)]
required: Seq[(String, String)]

Any ideas? Thanks!


Try breaking it up into a few steps.

val choices:Seq[(String,String)] = ("","") :: (all the rest of your options here)

scala> ("","")::List(("c","d"), ("d","e"))  
res8: List[(java.lang.String, java.lang.String)] = List((,), (c,d), (d,e))

Then use that choices var as input to the SHtml.select method. There's nothing preventing this approach from working.


Example of I82Much has problems with compiling and shows errors. I have modified his answer and have no problems. Tested.

define variable:

val choices = List(("",""), ("S", "Storage"))

and then use it

"strType" -> SHtml.select(choices, Empty, storage.strType(_), "class" -> "smallInputSelect"),
0

精彩评论

暂无评论...
验证码 换一张
取 消