Search code examples
scalaflashplayframework-2.6

Using Flashing and Implicit Message at the same time


I already have implicit message to be returned to the template but want to add flashing only if it fails to the login test.

Below is the code from my controller:

Action.async { request =>
....
if(not a valid id or password)
    Redirect(routes.Admn.login).flashing("error" -> "Invalid Username or Password")
}

And this is from my template scala.html:

@(data: Form[MyForm])(implicit message: MessagesRequestHeader)
<body>
//user name input text
//user password input password
@flash.get("Invalid Username or Password")
</body>

this brings value not found flash error. it still doesnt work after adding @()(implicit flash:Flash). Any one have a good idea to make this code work?


Solution

  • @(data: Form[MyForm])(implicit message: MessagesRequestHeader, flash: Flash)

    in my template worked. Initially, thought that I am not allowed to add 2 params(?) in (implicit ~~ )