我有以下表格:
<form class="lift:form.ajax">
<div class="lift:StreamInput">
<input type="hidden" name="user" value="USER" />
<input type="hidden" name="room" value="ROOM" />
<input type="hidden" name="path" value="PATH" />
<input type="hidden" name="level" value="LEVEL" />
</div>
<input type="submit" value="" />
</form>
进入:
object StreamInput {
case class StreamItem(
user: String,
path: String,
level: String,
room: String
)
def render = {
var user = ""
var path = ""
var level = ""
var room = ""
def process(): JsCmd = {
var message = StreamItem(user, path, level, room)
StreamServer ! message
}
"name=user" #> SHtml.onSubmit(user => user = _)
"name=path" #> SHtml.onSubmit(path => path = _)
"name=level" #> SHtml.onSubmit(level => level = _)
"name=room" #> (SHtml.onSubmit(room => room = _) ++ SHtml.hidden(process))
}
}
编译时我遇到以下错误:
"Missing parameter type for expanded function ((x$1) => user = x$1)"
"name=user" #> SHtml.onSubmit(user => user = _)
^
"Missing parameter type for expanded function ((x$2) => user = x$2)"
"name=path" #> SHtml.onSubmit(path => path = _)
^
"Missing parameter type for expanded function ((x$3) => user = x$3)"
"name=level" #> SHtml.onSubmit(level => level = _)
^
"Missing parameter type for expanded function ((x$4) => user = x$4)"
"name=room" #> SHtml.onSubmit(room => room = _)
^
我一直在谷歌搜索一段时间,似乎无法找到适合我特定情况的解释。
不确定我缺少什么,非常感谢任何帮助,提前谢谢:)
答案 0 :(得分:0)
SHtml.onSubmit
需要回调(String) ⇒ Any
。 String
是新提交的字段值。在您的情况下,您希望提供一个setter方法,将var
更改为该新值。将参数更改为
SHtml.onSubmit(user = _)
或扩展
SHtml.onSubmit(text => user = text)