0

index メソッドで、 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[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.

4

1 に答える 1

2

ジュリアンが述べたように、これは機能しています:

@main(title = "myTitle", form = form) { … } or just @main("myTitle", form) { … } 
于 2012-05-23T06:41:12.897 に答える