This project is read-only.

Create custom content parts for user-created forms?

Topics: Writing modules
Feb 21, 2012 at 10:11 PM

I've been thinking about if it would be possible to implement something like Countor (from Umbraco) for Orchard. Basically, what I need to create is a way for the user to create a custom form with some fields to present on the front-end of the website. This wouldn't be that hard to create and then store the data or send it by e-mail.

But then I thought it would be cool if the data could be used outside the module and used by maybe Projector. That would however require the different forms to store data in a way Projector can use. Is there any chance anything like this would be possible?

Feb 22, 2012 at 1:32 AM

I don't see why not. By the way, there is a forms module on the gallery already. I've never tested it, but it exists.

Feb 23, 2012 at 5:41 PM

As far as I can understand Projector can create binding of stuff that inherit from the ContentPartRecord class. But if I should be able to use the form-entered data with Projector, I would need to have a ContentPartRecord for each type of form. But is it possible to create this dynamically? (And if, how?)

With the forms module I found you had to manually enter the HTML code for the form, which won't work if the user doesn't know HTML.

Feb 23, 2012 at 10:02 PM

If there is an editor for what you bind, it will get used. Otherwise, yeah, sure, you need to create it. Or did I misunderstand your question?

Feb 28, 2012 at 1:56 PM

I don't think Projector is the right way; it creates views of existing data / content types, whereas you want a UI for the user to build something custom.

One relatively simple option is to create a content type out of fields and existing parts, then grant Anonymous users permission to create that type, surface an editor in the front-end (can be done straightforwardly from a controller with a call to IContentManager) and finally hook up Rules to send an email whenever the content type is created. As a bonus, it'll already be stored in the DB.

That whole process could be wrapped up quite nicely in a module to automate the workflow a little, but as you can see it's pretty much possible already with minimal coding. (The other thing you will need is a handler to prevent the created items being publicly viewable on the default /Content/Display/{id} route!)

Feb 28, 2012 at 9:18 PM

Well, I guess even I misunderstood my first question, but after Bertrand dragged me off the wrong path I think I know how I can do it.

Anyway, what's wanted:

An entry form where people can register for an event. The site owner wants name, email and company. So, a front-end form for that is required. When an entry is made an email is sent to the admin. In the backend the administrator wants a checkbox to check if the person has paid the fee. Finally a list of people who paid should be displayed front end.

So, the email thing is fixed by Rules, and Projector can display the list of people.

The thing now is the front-end form. I will create a content type with the required field, and then I would like a module, as Pete suggest, that not only simplifies the workflow, but also can select which fields to display. I would probably have three textfield and one boolean here, and I don't want to show the boolean "Has paid" one front end when the user registers.

Well, I guess I kind of know what to do, so I'll try.


Thanks guys!