Form (). bindFromRequest () with array values
I have <select name="items" multiple> in the interface and I use form (). bindFromRequest () to the backend, and then using DynamicForm.
But here is hic:
DynamicForm form = form().bindFromRequest(); form.field("items").value(); // Only return one value ! How can I get all the value presented? without having to go through request().body().asFormUrlEncoded().get("items") , if possible.
Thank you for your help!
Binding array values ββrequire the correct value to be specified in the query. The parameter name must end with "[]" to bind as an array (list) value.
In your HTML you should have:
<select name="items[]" multiple> In the form class add it as:
public class ExampleForm { public List<Integer> items; } I know that this does not solve the DynamicForm problem, but it is a much more elegant solution.