SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating forms at Run Time

    Hi !

    My company have a site that has some important forms. Now, we want that the we may have a tool where we can create / edit our forms.

    Each form is tied to a database table, and know that it is some thing that needs a lot of effort.

    We plan to have about 30 new forms, and this causes us to think for a form creation thing.

    My question:

    I plan to have an area in our system where the administrator can login, and create the form and give it a name. Then, the admin will click on Add fields,
    then he can enter the field name, and select the type. (Dropdown, Text, Check box, and radio box) if it is text field, then it is simple, but if it is a Check box, radio box and/or the dropdown, then it will ask for the options and their text.

    So I have to setup a few more tables:

    1) Form master
    2) Form Fields
    3) Form Fields options in case of Check Box, Radio Box, and dropdown.

    Now, when some one fill in the data in that form, i m stuck here, how and where the data will be kept ? can any one please guide me on this ? or can give me a better idea ?

    Thanks
    Zeeshan

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    This, currently, sounds more like a database issue; I'll move the thread there for now.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any one ? Please guide !

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,146
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    Unless the domain is modeled in the exact way as the database, this is probably a bad idea. I mean the abstraction that occurs between the domain and databases happens for good reason. Removing that abstraction is going to make things a nightmare for none-technical users. The more they will have to understand in regards to how things work from a programmatic stand-point. People are really stupid so the more things can be abstracted and be presented in a more understandable format that reflects the business model at hand the better. In most cases business work flow never directly correlates to the database structure without different levels of abstraction and organization that is just about impossible to automate unless many sacrifices are made. Even at that point there is always edge cases that are difficult to for see in the beginning. Now, I'm not saying it can't be done what I'm saying is in all cases it results in a sacrifice in terms of usability for the average user. Than again I guess I would need to know about the a specifics of these 30 forms to say for certain. What you are essentially talking about is scaffolding though. Most frameworks have a feature to read the model and create a form. The form is just a list of everything in most cases, no organization, tabs, logical grouping, etc but a form none the less. Having said that would this be a single form per table? If it is one form to a table its probably easiest to skip having form tables and derive the form based on the tables schema with widgets that are based on data type of whether the column is a foreign key perhaps. Though again as a programmer you always have to remember the majority of users are idiots. Usability decreases as abstraction decreases unless you start to make sacrifices in terms of the database structure itself.
    The only code I hate more than my own is everyone else's.

  6. #6
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol. oddz.

    ironically, you lost me after "people are really stupid."

    interesting subject though and one in which I too have an interest. Are you suggesting that compiling the structure of a form is overly difficult for a non-tech person? if so, I tend to agree and I am seeking a way of keeping it simple yet flexible.

    (hopefully not construed as a hi-jack).

    bazz

  7. #7
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi !

    @r937

    I do not want to create the database tables when the form is created. I only want to keep the form's, form's fields and options of form's fields in the tables so that on the frontend, I can pick the form id, and get all the fields/lebels associated with that forms and in case the field is check box/ radio button and dropdown, then also collect the options for those fields.

    So I plan to have my schema like this :

    1) Form Main (here I will keep the main data about the form, like name, id and description of the form) for example, A BUSINESS PROPOSAL FORM

    2) Form Fields (here I will keep data about all the fields in the form) for example,
    First Name, text field,
    Last Name, text field,
    Grad Year, dropdown
    Practicing Area, check box

    3) Options of Form Fields (here, I will keep the options for the form's fields if they are Drop down, Check box and radio button.) For example,
    the ID of the form field from the 2nd table above, and then value/text. suppose that the ID of Features field above is 52 so it will have :

    52, Medical Science
    52, Medicine Science
    52, Bio Tech
    52, Microbiology
    52, etc etc etc

    Now, when my script get a form ID, it will grab the form details from the Table no. 1, and collect the fields and their options from Table No. 2 and 3. and now the form is ready to fill and submit.

    Now, the issue:

    To collect the data user enters on this form, what is the best approach ? I do not want to have 1 table for each form type. It will be 1 table for all the forms I have.

    Can I have a table like this:

    ID, Date submitted, Form Id, Field Id, User Entered data

    Example:

    1, 2011-02-01, 13, 1, Zeeshan
    2, 2011-02-01, 13, 2, Hashmi
    3, 2011-02-01, 13, 3, 2009
    4, 2011-02-01, 13, 4, Medical Science
    5, 2011-02-01, 13, 4, Microbiology

    Suppose that user enters names and grad year and then select the 2 check boxes for Medical Science and Microbiology ?

    Can I achieve the same by saving my data as a XML ?

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by zeeshanhashmi View Post
    Can I have a table like this:
    yes, but you are giving up all hope of data integrity if you do

    Quote Originally Posted by zeeshanhashmi View Post
    Can I achieve the same by saving my data as a XML ?
    probably
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Is there any way to achieve this that you people may suggest ?

  10. #10
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So many people around but not a proper suggestion ! - Heartbreaking !

    Anyways.
    Thank you everyone.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •