I have a request form on two pages of my site: About us and Contacts. Actions for both of them described in my Home controller. After submitting the form I call sendRequest method, which checks form errors and sends request. This method looks like:
def sendRequest = Action {implicit request =>
requestForm.bindFromRequest.fold(
formWithErrors => {
BadRequest(views.html.Home.contacts(formWithErrors))
},
response => {
Redirect(routes.HomeController.contacts().flashing("success" -> "OK"))
}
)
}
In this method I define view and route to navigate. And for my About us page I should do the same work, but call about us view and route.
How could I create generic method and call it with concrete view and route as parameters?