【发布时间】:2012-05-23 14:41:12
【问题描述】:
在我的索引方法中,我呈现了一个基本的登录表单,我将其发送到我的 index.scala.html:
/**
* Main entry method for the application
*/
public static Result index() {
return ok(views.html.index.render(form(Application.Login.class)));
}
在index.scala.html文件中:我已经定义了form参数:
@(form: Form[Application.Login])
@main(title = "myTitle") {
<h2>Testing app</h2>
}
因此,在这个文件中,我通过 @main(...) 调用父模板。但是如何将 form 传递给我的父模板?我尝试了以下方法:
@(form: Form[Application.Login])
@main(title = "myTitle", form) {
<h2>Testing app</h2>
}
以及在我的 main.scala.html 中:
@(title: String, form: Form[Application.Login])(content: Html)
但这不起作用,我收到以下错误消息:
not enough arguments for method apply: (title: java.lang.String, form: play.data.Form[controllers.Application.Login])(content: play.api.templates.Html)play.api.templates.Html in object main. Unspecified value parameter form.
【问题讨论】:
-
这可能是由于使用了命名参数而导致的问题。试试
@main(title = "myTitle", form = form) { … }或只是@main("myTitle", form) { … } -
朱利安,是的,它正在工作。只需要清理和运行我的应用程序。谢谢