Form Generator – Further thoughts

I have been putting some more thought towards a form generation script. I have been working on initial class diagrams. Most of my work has been put towards how to easily add form field types. This I feel will be the hardest part of this project. The only other data that needs to be held is an id or name for the form, a url that the form goes to, and a url to go to if the user presses a cancel button (or if there even is a cancel button.)

So when it comes to individual fields the following is a list of data that I think we need to build any given form field:

  • Field Name (should be unique, will be used as the name and idĀ attribute)
  • Field Type (text, password, string, etc.)
  • Required Flag
  • Field Label
  • Field Parameters (these could be used to build lists or to set field restrictions.)
  • Default Value

There of course would have to be programming to implement each of the different field types. I think the best way to implement this would be to introduce a function for each field type. This function would accept the following parameters:

  • Field Name
  • Required Flag
  • Field Label
  • Default Value (might be an array if there are multiple values necessary.)
  • Field Parameters (like I said, these would just help in building the element and setting restrictions.)
  • Error message (If one exists.)

There would also need to be a function that handled the validation of each field. This function would accept the following parameters:

  • Field Values.
  • Field Parameters.

So I would need to create a class that will form the interface into the system. This class would have to have the following functions:

  • Initialize Form (this will take form wide parameters.)
  • Add Field (This will create a field and will accept a field type and all the paremeters mentioned above.)
  • Execute (this function will check for a flag to see if the form has been submitted already.)

Tomorrow I should be able to get a good start on the coding.

Leave a Reply

Your email address will not be published. Required fields are marked *