views:

117

answers:

5

I am developing an application in which I would like to let the users design some forms and decide the fields that are in the form.

An example is better than a poor explanation, so let me put the example of Microsoft CRM in which you as end user can define a form, the fields in that form, or customize existing forms by adding or removing fields.

Is there some standard way to do this?, Anyone knows of components to use? Or worked in a similar functionality?

Any put would be appreciated.

A: 

In my current project, we let the users customize the fields they want to see in the search forms and the results grid by storing per user configurations. Example, user A wants to see P,Q,R on form X, Each control has an Id and the config values are stored by the Id. May not be very elegant, but works for minor customization.

DevByDefault
What I was searching is to let the user add completely new fields, not only to choose from a predefined list.
Doliveras
+3  A: 

This is not a trivial undertaking and there are thousands of ways to accomplish this. It depends on many factors - e.g. will your users be able to "publish" their created forms, can the users update their forms (brings in form- and data-version management issues), will you provide a visual designer, will you provide a declarative design language, how do you want to store the data filled into a form, are the fields chosen by the user pulled from a finite set of available fields or can the user invent wholly new fields, etc.

In a full-blown electronic forms package, you are, essentially, creating a visual IDE for form creation along with a "compiler" that produces the fill-able, run-time implementation of the user's forms. To make the system useful, you will also have to include management features (search, filing, import, export, etc.).

If you don't want to tackle these issues yourself, there are many eforms packages out there. Cost ranges from free to tens of thousands of dollars.

Chris Judge
A: 

I would suggest that you create a form layout generator, that takes input the columns to display, and the kind of control to edit them. It should then arrange the columns in a ordely fashion (utilizing flowpanels or something similar). Dynamically creating columns in the database is easily done. Then the user can spesify the columns they want to edit in a grid or something like that, the layout engine then creates the form from the columns spesified by the user. Of course that limits the posibilities compared to a completely free gui designer like visual studio itself, but it will also make the forms look ordely and nicely aligned. So all in all a good tradeoff, and much much simpler to implement than a full blown gui designer.

sindre j
+1  A: 

This is a very complex problem, I will first simplify it to a simpler use case, and then give a possible design approach.

USE CASE:

  • User wants to design a form using a gui. Many fields(such as name, email, age) are possible as are input
  • options(text field, selector, radio buttons) Output is an XML form or object construct for your application.
  • user selects saved XML form to generate new form object or uses gui to select new form elements to add to a from, providing the form name and field type and if a selector the valid inputs list

DESIGN:

  • Provide a standard set of input objects(text field, selector list, etc.) as objects.
  • Provide a base From object which is a container for input objects, with a map of input labels to input objects.
  • Provide a separate From View object that handles presentation of a form object(as in the View portion of MVC)

I think the best way to start at this would be to build a piece software that parses a standard html form and creates and object in you application. This is then displayed by your GUI. Once you can parse html forms you know you have the needed fields and the ability to display them, now you just need create a gui to allow the user to add elements to a form object.

All that being said, this is not a simple task. There are a lot of ins, a lot of outs, a lot of what-have-yous in this sort of feature.

kramthegram
A: 

As everyone said, this is very difficult so let's look to standards. The standard for composing forms is HTML. So you:

Let users create forms/fields using html or any HTML designer.

Embed IE in your application to render the html.

Spin some sort of tiny webserver on their machine that accepts requests from this Form and this form only (I think some of the stuff in ASP MVC would be of help here)

When they submit the form parse the Request Post to see the fields and values.

George Mauer