Its really easy to get form value in scala html file (in view). First take a look
at how form is defined in the controller. I have only added related code snippet.
mapping(
"courseId" -> nonEmptyText,
"name" -> nonEmptyText)
Now look at my scala.html file. Following code will accept the course form as a
parameter.
@(courseForm: Form[Course])(implicit request: RequestHeader, flash: Flash)Now you want to access the 'courseId' in courseForm. First I print the value like this.
@courseForm("courseId")
But this will not work because it prints list of values because it is reference
to the Filed object itself not to the real Id value. Now I do like this.
@courseForm("courseId").value
This will print the real Id value. (@ is to print something in scala html file)
Comments
Get form value in scala so difficult for me.
You save my time
Thanks!.