Announcement Announcement Module
Collapse
No announcement yet.
How to use @Valid if my form has some fields for 2 models? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use @Valid if my form has some fields for 2 models?

    I have a form where I have some fields for my models Project and User (note, I don't have all the fields for either).

    This is a spring mvc application.

    This is what I have now, but it is for only 1 model (Project), I need to now add some properties in my form for the User (but not all):

    Code:
    public ModelAndView create(@Valid Project, BindingResult result) {
    
       if(result.hasErrors()) {
    
       }
    
    }
    How can I validate both models when the user performs a post to my controller?

    I think that I may have to drop the @Valid in my controller and then do this programatically then right?
Working...
X