You do not need to pass it twice (via the route argument and the hidden form field), so you have two solutions: use only route arg:
Route argument
way
GET /service/register controllers.WebRegister.register(plan: String?="")
template
@form(action = routes.WebRegister.register("free")) { <input type="submit"> }
Of course, if you have only one field, you can directly use the link:
<a href='@routes.WebRegister.register("free")'>Register free</a>
java action
public static Result register(String plan) { return ok(plan); }
Form field only
remove the argument from the route and associate the field with the request in the controller:
way
GET /service/register controllers.WebRegister.register
template
@form(action = routes.WebRegister.register) { <input type="hidden" name="plan" value="free"> <input type="submit"> }
java action
public static Result register() { return ok(form().bindFromRequest().get("plan")); }
source share