DetailFormFor don't execute IValidatableObject

Jul 21, 2011 at 7:13 PM

Hi,

I'm using a DetailFormFor where the model implements IValidatableObject, but the dialog don't show the validations messages from IValidatableObject, only attributes validation (like RequiredAttribute) works. Is possible use IValidatableObject with DetailFormFor?

Thanks.

Coordinator
Jul 22, 2011 at 7:41 AM

No Detail windows supports any type of validation. 

As first stem make sure you are using the 1.1.0 RTW rlease.

Now if this is the case, probably the action method you are using to return your detail view is not a:

MVCControlsToolkit.Controller.ClentValidationViewResult

You have to return this kind of PartialView when your PartialView doesn't contain a form tag inside it, as it is the case when you use a detail form. 

During the partial view rendering if the content IS NOT rendered in a form the MVC engine doesn't render the errors, because all errors are associated to a form.

Now the ClentValidationViewResult create a FormContext, and then, on the client side associate the errors to the pre-exixting form.

Summing up:

1) Verify you are using the last verxion of the Mvc Controls Toolkit

2) Use the ClentValidationViewResult (see the detail form of the  BinariesWithSimpleExamples file)

3) The partial View of your detail form must have its own validation summary. Errors will not be added the the validation summary of the whole View(this is for errors coming from the submit of the whole View).

4) Make sure you put the detail form helper outside of any form, since it renders its own form.

Jul 22, 2011 at 11:19 AM

Thank you!