views:

18

answers:

2

I'm working on a really big order form with a bunch of multi-part data that's submitted all at once. I'm using that trick where you render 30-40 item rows in the HTML and allow the user to "show" or "hide" more or less using jQuery.

The problem is that while the user may have, say, three rows "showing" and they happen to fill all three out completely, my model will never validate because there's an additional 27 invalid (empty) items being submitted as well.

My solution was to say screw the built-in model validation and use some custom model validation a la ModelState.AddModelError(), but I feel like a douche having to repeat my model validation at the controller level.

Is there a better way to handle this?

A: 

Split the large form into multiple forms. Each form will represent a different step. Split your large model into multiple view models each corresponding to a given step. Progressively enhance with jquery if you wish to ajaxify the form submission and show/hide steps.

Darin Dimitrov
A: 

Thanks, but I just iterated through each row and removed empty rows from the DOM on the onclick event of my submit button using jQuery.

Derek Hunziker