I have a play GET route, how can I use it in scala html form?
routes
GET /service/register controllers.WebRegister.register(plan?="")
scala html
@form(action = routes.WebRegister.register, 'style -> "width: 320px;") {
<fieldset>
<input type="hidden" name="plan" value="FREE" id="plan">
</fieldset>
<div class="form-actions plan-form peer-btn-center peer-m-v-t">
<input type="submit" data-icon='󦙠' class="btn btn-primary btn-large" value="Sign Up">
</div>
}
It gives me an error:
missing arguments for method register in class ReverseWebRegister; [error] follow this method with `_' if you want to treat it as a partially applied function
You don't need to pass it twice (via route argument and form's hidden field) so you have two solutions: use only route arg:
route
GET /service/register controllers.WebRegister.register(plan: String?="")
template
@form(action = routes.WebRegister.register("free")) {
<input type="submit">
}
of course if you have only this one field you can use link directly:
<a href='@routes.WebRegister.register("free")'>Register free</a>
java action
public static Result register(String plan) {
return ok(plan);
}
remove argument from the route and bind field from request in controller:
route
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"));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With