score:1

you can simply wire this in through your controller.

  def myview(): action[anycontent] = action { implicit req =>
    val userid = req.session("user_id")
    val user = finduser(userid)
    results.ok(views.yourform(itemform, user))
  }

then in your view:

<p class="username">${user.name}</p>

the finduser method or whatever will allow you to search for a user based on some kind of data within the request. req.session(key) will return null if the user is not logged in potentially so you may want an option[user] instead.

the point is that you can pass through whatever variables to your form, and use @{variable.field} syntax to display whatever you like. the twirl syntax allows you to do this, as well as for loops on collections to create a div for each element etc.

have a quick read through the twirl syntax, it should help you see all the examples of what it can do. to "get the data", it's generally preferable to put your logic in the controller, and pass it to your view.


Related Query

More Query from same tag