Compilation error: missing arguments for method apply in class newPost; follow this method with `_' if you want to treat it as a partially applied function
I don't understand how template handling methods have to look like and what complier require of me.
https://github.com/flatlizard/blog
controller:
def addPost = Action{ implicit request =>
Ok(views.html.newPost(postForm))
}
def createPost = Action { implicit request =>
postForm.bindFromRequest.fold(
hasErrors => BadRequest,
success => {
Post.create(Post(new Date, success.title, success.content))
Ok(views.html.archive("my blog", Post.all))
})
}
routes:
GET /archive/new controllers.Application.addPost
POST /archive controllers.Application.createPost
view:
@(postForm: Form[Post])(content: Html)(implicit messages: Messages)
@import helper._
@form(routes.Application.createPost) {
@inputDate(postForm("date"))
@textarea(postForm("title"))
@textarea(postForm("content"))
<button id="submit" type="submit" value="Submit" class="btn btn-primary">Submit</button>
}
UPDATE
I solved problem adding the following imports in controller file:
import play.api.i18n.Messages.Implicits._
import play.api.Play.current
See Play 2.4 migration: https://www.playframework.com/documentation/2.4.x/Migration24#I18n
I solved problem adding the following imports in controller file:
See Play 2.4 migration: https://www.playframework.com/documentation/2.4.x/Migration24#I18n
Update
Actually this is a bad way cause here used Play.current which will become deprecated soon. Here another solution using dependency injection:
routes:
controller:
https://www.playframework.com/documentation/2.4.x/ScalaDependencyInjection