This project is read-only.

What is the best approach with forms in modules?

Topics: Writing modules
Jun 12, 2012 at 10:58 PM
Edited Jun 13, 2012 at 5:22 AM

I am still very new to Orchard and I am trying to understand what the right approach is in creating a module. This module doesn't use the CMS database for my module data but integrates with an external web service for accessing and modifying data. Based on various tutorials I have so far managed to create a module with a part for configuring the web service access and I can show different custom views (widget) of the data.

I now need to create a form for posting data to the service. I am now wondering what the best approach is. I intend to have the driver return an additional display shape for the form by combining shapes and then use placement info in the theme to control where it should be displayed. The post action would be handled by a normal MVC controller, which I would add to Orchard routes.

Is this a good approach?

I have also looked at using form and workflow functionality in existing Orchard modules but I am not sure how to do this from a module. Also, in my case I don't want to keep any workflow states in the CMS database since this is done by the web service.

Jun 13, 2012 at 5:25 AM

Sure, that's a good approach, that I've used successfully on past projects.

Jun 13, 2012 at 6:16 AM

Thanks a lot, this wasn't entirely clear to me. How would you then get part data to the MVC controller, which handles the post request? The part contains configuration information in my case.

Jun 13, 2012 at 6:24 AM

The template for the shape that your part driver rendered has a form. It's just a matter of making sure the form fields correctly map to the action parameters. Exactly like in regular MVC.

Jun 13, 2012 at 6:25 AM

Forget the question. I can myself just read the information from the database. Sometimes I don't see the obvious in all the complexity.

Jun 13, 2012 at 6:26 AM

Thanks for that answer too. I consider this option as well.