2

I am working on a form-generator, however , I was confused when attempting to create the database for it.

The requirement is divided into backend / frontend,

For backend, the admin can manage the form

  • specific form name
  • manage the form input (only input box , select box , check box are allow)
    • input title
    • is required?
    • if selectbox:
      • option name , value
      • *is pop up other input when I select the value?
    • if input box:
      • is numeric / string type?

frontend: can store the form value

The problem are:

1) For the * , For example, if the user select option A , then the option C is visible , otherwise , it is hidden , how can I store the relationship?

2) How can I store the value in this form ? If I put in one table / the value are possible to be varchar / float / integer / tinyint

Thanks for helping enter image description here

user3538235
  • 1,991
  • 6
  • 27
  • 55
  • 1
    Would you please go for an explanation regarding problem 1 ? – 1000111 Mar 03 '15 at 07:27
  • 1
    I used html-generator library to generate the forms, for this you can store structure of forms in a table and each time you need a form to display use from that table and parse the structure to make the form. For Storing data of form you can use pivot structure. – Mobasher Fasihy Mar 03 '15 at 07:36
  • that means , first of all, the admin can design the select box in the form, and for the select box option ,it can be specific whether it show the other input box when it selected. – user3538235 Mar 03 '15 at 07:39
  • for example, when optionA in input box A (which is a selectbox) is select, then show input box B , otherwise box B is hidden – user3538235 Mar 03 '15 at 07:41

1 Answers1

2

Possible Suggestion for Problem #1:

You might send the mapping (i.e. selection -> input_filed) from backend. Then after receiving the mapping from back end you can make your conditional form inputs ).

Suppose, from back end you send this:

  • IF I select A input filed F1 will appear.

  • If I select B input field F2 will appear.

For implementing this of course you must have this mapping in one of your tables in your database. Then the rest will be done in front end.

Possible Suggestion for Problem # 2:

Method 1 :

You may keep a table where it will act like a super class. That means all the possible types (varchar / float / integer / tinyint) should exist in your table.

Disadvantage : waste of space because for each entry in this table only one field will be filled up others will be left blank.

Method 2 :

You should not use MYSQL for this purpose. You may use any NoSQL database. Please have a look at this post. Go through this. I am sure you will get an idea. dynamic columns and data type in mysql

Method 3 : There are so many ways. These links might help.

How to design a database for User Defined Fields?

https://softwareengineering.stackexchange.com/questions/204097/dynamic-form-builder-forms-and-database-design

Good Day!!

Community
  • 1
  • 1
1000111
  • 13,169
  • 2
  • 28
  • 37
  • thanks , for the problem 2 , can it be slove in application level e.g. store the type for each table e.g. int_val , varchar_val , bool_val etc.. as mysql is only choice for now , thanks – user3538235 Mar 03 '15 at 08:16
  • Hi I've edited the answer. Added some links. Please go through these links. You will get more ideas. Thanks. – 1000111 Mar 03 '15 at 09:36