I’m have a fair complex Form that I am trying to create in Play Framework 2.0. Instead of having all of my fields in the main form model class, I have broken it up into sub-objects. This unfortunately does not seem to be working for validation constraints. The binding does seem to work so I do end up with the object being properly populated.
Is there some way to get validation to work on sub-objects. See the following model and view code. The Email Address under the client is is not being validated.
Form Model:
public class Inspection {
// This works!
@Email
private String email;
private Client client;
// ... getters and setters
}
public class Client {
// This does not work
@Email
private String email;
// ... getters and setters
}
View:
@inputText(inspectionForm("email"), '_label -> "Email Address 1")
@inputText(inspectionForm("client.email"), '_label -> "Email Address 2")
Try using the @Valid annotation on client