dynamic forms

Topics: Customizing Orchard, Writing modules
Apr 4, 2011 at 6:43 AM

Hi All,

Anyone have the experience to create the dynamic forms in orchards? I wish to create the module that allow end user to create their own forms.

If company have any event or seminar, Admin can create the new form with necessary field on orchards. and user can register their info and submit back to admin online.

Thanks you so much


Apr 4, 2011 at 9:13 AM

You can create your own Content Type in the Dashboard interface and add any fields you like to it.

You'd then need to create a Content Part that would take all the fields on a content item and email them to admin. I haven't seen anything like this but it sounds pretty useful, so if you have any success it'd be a good thing to upload to the Module Gallery :)

Currently there's no decent way to customise the labels for each field but I already wrote a patch to enable this in Orchard 1.1, see: http://orchard.codeplex.com/discussions/251420 - it's a bit tricky getting it going but once you've run the DB migration it works fine.

Apr 7, 2011 at 8:46 AM

Finding that DotNetNuke has already Drag and drop ability for fields control onto dynamic forms. Could Orchard Teams plan for this kind of tool feature module? Not only DotNetNuke, drupal has graviti form feature integration also.. Currently we still face out the limitation of creating dynamic forms. The user can't create form as simplier as no drag and drop function



Apr 7, 2011 at 12:42 PM

Hi vteck, I'm quite interested in this. Could you provide a link to the Gravity system you mentioned, I can't find any info about it?

Orchard is in very early days whereas DNN and Drupal have been around for a long time so of course many advanced modules and systems have been developed for them.

Drag and drop is an extremely complex thing to implement effectively in web UI (especially for a modular, composable and templated system like this) ... but it's something I have a certain interest in. In fact some work I've been doing might interest you quite a lot, but at this stage it's far from ready to talk about. Let me just say there are aspects of the overall design of Orchard that would certainly make these scenarios possible, and I am certain that it will happen one day, if not sooner :)

Apr 8, 2011 at 2:12 AM

Hi randompete,

  Here is the link: http://www.gravityforms.com/  . Please take a look.

Apr 8, 2011 at 2:49 AM

Ok ... well it's quite a nice system, but the drag and drop I see doesn't really seem to do much, it just allows you to move fields from one column to another; you could achieve the same interface with checkboxes. I think I can come up with something a bit nicer that does more than just edit contact forms :)

Don't hold your breath though; I'm commited to a few things right now and it'll take a while to implement what I've got in mind...

Apr 8, 2011 at 2:53 AM

It's great to hear that. Yeah, we may put drag and drop ability aside first. At least focusing on more dynamic and flexibility to let the user to choose the controls first in order to create a new form. Do you have any idea how to start it? Thanks.

Apr 8, 2011 at 2:54 AM

BTW - to kytan as well - Orchard can already build dynamic forms perfectly well, in the Content Type designer. It just doesn't have any fancy drag and drop, but you can perfectly well give admins the ability to create their own content types which users could fill out. There's a bit of configuration and juggling to get the form appearing in the front-end for users to fill in, and have it email back to admin; but it's all possible and there might already be modules on the Gallery that assist with this.

Apr 8, 2011 at 2:56 AM

A user can add any number of fields to a content type. What can't be customised in the default installation is the DisplayName, but I made a patch to add that and then discovered there's an easier way, by adding a field setting for it. I'll probably get around to wrapping that up as a module at some point...

Apr 8, 2011 at 3:41 AM

Hi randompete and vteck, thanks for reply. I'm new in orchard and MVC, after few days cracking my head on this, I have some idea.

first initial idea was
Step 1: admin create the fields that need in content type.
Step 2: have a module that generate the fields in content type become cshtml forms and setting page.

But it may have sequence and Display Name problems (the display name can solve by using the patch you added)

so may be i need to create the module allow user key in the fields that need
eg like: sequence, FieldName, DisplayName (in future can add in datatype, validation check and so on..)

after user complete the fields need then click next to enter the Form name and send email to.

in the last step of the module is generate the cshtml form to orchard front page.

is this work?

Apr 8, 2011 at 3:55 AM
Edited Apr 8, 2011 at 3:55 AM

Orchard will handle the html form generation from the fields and parts on the content type. You need to look at what happens in the various AdminControllers in Orchard modules (particularly Orchard.Core.Contents) to see how the Create/Edit actions render an edit form instead of a normal display.

It's possible to add more settings to a field (which is the better way of doing DisplayName that I haven't got round to yet). Look at the Indexing module to see how it adds the "Include this field in the index" setting.

Then you could use an IShapeTableProvider to look for the Sequence setting and change the position of the fields accordingly. Ordinarily you'd be able to do this in Placement.info (at least in version 1.1) - but obviously your admins won't have the ability to edit that file!

Finally you could also use Shape display methods to construct the email to send to admins. However this will be a bit tricky and you could just use a simple module I released - Content Notifications - this will email the admins whenever items are published (only items with the ContentNotification part attached) and the email has a link back to view the item on the site. So the details wouldn't be in the email but they could be quickly looked up and would be stored in the site database.

So I hope this gets you at least some of the way there, let us know if you hit any roadblocks :)

Apr 13, 2011 at 7:25 AM

Hi random,

  Have you tried it out for customisable form? Probably you could share it with us for your finding of wrapping out as a module. Thanks.