0
在我的索引方法我呈现一个基本的登录表单,我发到我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[Application.Login])
@main(title = "myTitle") {
<h2>Testing app</h2>
}
所以,在这个文件我用@main调用父模板(...)。但如何将表格传递给我的父模板?我曾尝试以下:
@(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”,表单){...}' – 2012-04-09 08:49:59
Julien,是的,它工作。只需要清理并运行我的应用程序。谢谢 – adis 2012-04-22 19:35:13