Reputation: 39889
I have a <select name="items" multiple>
in the front end, and I'm using form().bindFromRequest()
in the backend, then using a DynamicForm.
But here's the hiccup:
DynamicForm form = form().bindFromRequest();
form.field("items").value(); // Only return one value !
How can I get all the submitted value? without having to go through request().body().asFormUrlEncoded().get("items")
if possible.
Upvotes: 5
Views: 2555
Reputation: 1536
Binding array values require to properly name value in request. Param name should end with "[]" to be bound as an array (List) value.
In your HTML you should have:
<select name="items[]" multiple>
In Form class add it as:
public class ExampleForm {
public List<Integer> items;
}
I know this not solve DynamicForm problem, but it is far more elegant solution.
Upvotes: 4