Reputation: 39859
I have a special input form (a select multiple) with the name "allergies" on my form, but it returns an error if I do :
Form<Child> form = form(Child.class).bindFromRequest();
from my server side, with "Invalid value" error.
For it to almost work, I should rename my field to "allergies.id" but I can't change it.
So I wanted to ignore this field for errors, and did something like :
form.field("allergies").errors().clear()
but then, if I do a
if (form.hasErrors())
it returns true, just for allergies.
How can I ignore the validation of allergies ?
Upvotes: 1
Views: 1151
Reputation: 7309
I'm not sure if it's very clever to manipulate the list. A more clean way is to bind only the fields you want. public Form<T> bind(Map<String,String> data, String... allowedFields) {
.
How ever form.field("allergies").errors().clear() can't work, because the you have an error map where for the key 'allergies' exists an empty list. form.errors().remove("allergies");
should work.
Upvotes: 4