开发者

Solution for creating dynamic forms

I'm having some trouble deciding which approach I should take. I want to allow users to create their own html forms by choosing different form elements (textfields, text开发者_JAVA技巧areas, lists, ratios, etc) I guess something similar to http://wufoo.com/ but much more basic. Should I use database tables or create files?

For tables I was thinking to create a table for each form element, e.g

TEXTFIELD TABLE

ID

TEXTFIELD_NAME

USER

...

TEXTAREA TABLE

ID

TEXTAREA_NAME

USER

etc for all form elements

and then just query all of them with..

WHERE user=$user

Or should I generate php files on the server for each form created?


One approach I used for custom forms on a mobile device was to define a table for field types (eg: text, date, money, custom), a table for form templates (with owner, version, and XML for the template data), and a table for form values (as XML) with a foreign key to the template.

Someone may create a form template with the available field types, and the collected data may be stored for that template, and optionally by template version. If the database supports it, you could query into the XML data to aggregate fields across forms.

For presentation, you could use a fixed style, or transform the template or collected fields however desired.


Should I use database tables or create files?

Storing this stuff in a database has the big advantage that you can easily edit them programmatically, and/or populate the user interface used to edit them.

A generated HTML structure you would have to parse first.

So definitely a database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜