Hi, I'd like to embed an instance of object A inside object B. I have already an action and an editing view which renders a form for object B. I made it a strongly typed partial view accepting B.
I am dealing with the Create action now, so I do b = new B(); b.A = new A();
Now I'd render the form for B, and then call the partial view for A, passing it b.A.
But what I get back is either a FormCollection, or my new A object with the B field set to null. In the first case all is well, but what will I do if the form fails to falidate? Do I need to create the objects manually with the wrong data and pass them again with an invalid ModelState? Is the second option ever possible?
Or do I just need to avoid having the nested view? I thought, as an alternative, to create a special model object just to handle the form with all the values for both A and B, and then when this form would validate I'd populate manually the A and B objects and save them... is this the only solution?