tags:

views:

40

answers:

2

I have a very large form I need the user to complete. They need to be able to save their progress whether valid or not. When they have come back at a later time, they can update and make valid - then submit the data.

I am using client side scripting (xval), server side attributes on the domain model.

A: 

One option for you is to have a [Save Draft] button which would go to a different Action SaveDraft() instead of Save(). By having a separate method, you can decide on the amount of validation you want on the Save operation. That I think is cleaner.

To have the same Save action decide whether to apply the amount of validatation logic would be harder to read and maintain.

Syd
My main problem is that I am using xval for client side validation... not sure how I can override that validation. I guess this is a question for the author. Also, need to just evaluate whether we need to give the user this ability (to save) because of there being several fields we will not want to even save without validating some of the input. We need to make some decisions here... thanks!
waynem
@waynem It sounds like you don't want to override the xVal validation. You want to either turn it off for that page so that the data can be posted or circumvent it with a jquery Ajax post.
Jace Rhea
A: 

I don't know much about xval, but maybe you can look into inheriting from xval attributes and doing the check there...

e.g. ConditionalRequiredAttribute : RequiredAttribute, which maybe can take the appropriate statuses to validate on.

Validation would be as simple as base.Validate() (or whatever it's called) on ConditionalRequiredAttribute's validate method if a validation condition is met (status != "Draft).

Since I don't know xval, I'm not sure how the client side validation works... does it create client side validation code? In this case, you'd have to write code that creates a similar wrapper in javascript (e.g. if(status != "Draft")... If validation simply makes an Ajax call to the server that returns a list of errors, then I imagine that you wouldn't have to do anything else.

Sorry I couldn't answer your question directly, but maybe this can help you come up with some ideas...

Giovanni Galbo