This project is read-only.

Submitting custom form / redisplay page after model validation error without using TEMPDATA?

Topics: Customizing Orchard, Writing modules
Apr 21, 2011 at 8:11 PM

I created a widget that represents a Subscription form. The form submits its fields to the action of a controller ('/mymodule/membership/create').
Now, in case of a model validation error, is it possible to somehow re-display the original page and display the ValidationSummary, just as with traditional MVC applications?
I checked how the Comments and ContactForm module implement this, and they are populating the TEMPDATA dictionary to re-display the posted values and redirect to the "returnUrl" querystring parameter. They also use an INotifier to display any error message (or success message, in case of the Comments module).

Is this the recommended approach? Because this way it looks like we're loosing the Html.ValidationMessage and Html.ValidationSummary helpers.
I could probably figure something out using Drivers instead of regular controllers, but as far as I know Drivers work with ContentParts, while my Subscription Form widget only works wih a viewmodel (the posted values are then posted to a webservice, where the data is stored; not in the Orchard database).

Any advice is greatly appreciated.



May 21, 2015 at 9:46 PM
Edited May 21, 2015 at 9:47 PM
So have you found any better solution? I ran into same problem. I made forms to use AJAX post and it solved the issue. However at some of the forms I don't want to use AJAX and what to do then?..