This is my Application.Scala
package controllers
import play.api._
import play.api.data.Form
import play.api.mvc._
import _root_.scala.xml.Text
object Application extends Controller {
def index = Action {
Redirect(routes.Application.tasks)
}
def deleteTask(id: Long) = TODO
val taskForm = Form(
"label" -> nonEmptyText
)
def tasks = Action {
Ok(views.html.index(Task.all(), taskForm))
}
def newTask = Action { implicit request =>
taskForm.bindFromRequest.fold(
errors => BadRequest(views.html.index(Task.all(), errors)),
label => {
Task.create(label)
Redirect(routes.Application.tasks)
}
)
}
}
I’m using play 2.0 framework. Where am I going wrong to get such an error?
You can browse Play 2 docs here. By looking at the index I found that
nonEmptyTextis contained in play.api.data.Forms object.So, you need to either add
import play.api.data.Forms._as already suggested or replace the current not found symbol withForms.nonEmptyTextsince it’s already imported.