I have a Controller defined like this:
package controllers
import play.api._
import play.api.mvc._
import models.Task
import play.api.data.Form
object Application extends Controller {
def index = Action {
// Compiler error on Form
Ok(views.html.index(List[Task](), Form("label" -> "This is a label")))
}
def tasks = TODO
def newTask = TODO
def deleteTask(id: Long) = TODO
}
Then I have defined a View:
@(tasks: List[Task], taskForm: Form[String])
@import helper._
@main("Todo list") {
<h1>@tasks.size task(s)</h1>
<ul>
@tasks.map { task =>
<li>
@task.label
@form(routes.Application.deleteTask(task.id)) {
<input type="submit" value="Delete">
}
</li>
}
</ul>
}
This gives the following compiler error:
overloaded method value apply with alternatives: [T](mapping:
(String, play.api.data.Mapping[T]))play.api.data.Form[T]
[T](mapping: play.api.data.Mapping[T])play.api.data.Form[T] cannot be
applied to ((java.lang.String,
java.lang.String)) Application.scala /todolist/app/controllers line
11 Scala Problem
Can you help me decipher the compilers output.
This is your problem:
Form("label" -> "This is a label"). You are trying to call methodForm.apply(p: (String, String))and there is no such method inFormobject.