Automatic Form Creation

Automatic Form Creation: A Project Proposal / Spec
Creating forms can be a very tedious and involved process, particularly if a substantial amount of formatting or value checking may be required. However, to a large extent, this process should be automate-able.To that end, I propose creating a PHP page that would automagically read an XML file and create an appropriate form. Because of the number of forms that needed creation on the website I worked on last summer, I implemented something similar at that time, and easily within a week saved more than the amount of time that had gone into developing the software.

I envision the implementation of such a form creator package to have two phases, looking something like this:

Phase 1: Get an automated form creator running which takes as input an XML file with specifics about the form to be created

Phase 2: Create an optional user interface that would create the file-based XML, allowing users to drag and drop (or otherwise add) various form elements to a GUI without needing to know anything about the backend XML structure

Phase 1 would require the following steps:
 * determine which form elements will be supported
 * determine what an end form might look like and create a stylesheet to power it (this needs to include some level of error-processing/checking to make sure all required form elements are supplied and valid)
 * determine the XML structure (I recommend XML because, as I learned, other forms of input do not allow the same flexibility that I came to need; while the XML may seem like overkill at first, it's a forward looking strategy that will allow greater expandability in the future; there is an example of what this may look like at the bottom of this page)
 * Create a PHP page that can read in a file from the file system (or perhaps from web-based input)
 * Add functionality to deal with the various form components (text input, radios, checkboxes, textareas, etc)
 * Add functionality to save these results to a new file
 * Lather, rinse, repeat until all form elements (and various options for each element) are implemented (for example, a radio selection might need to be horizontal or vertical, with labels or without, etc)

Phase 2 would require:
 * creating an entirely new front page GUI that allows users to add form elements either with little "+" buttons or by clicking and dragging, naming, and choosing options. This page would then save this XML (and eventually be able to read it back in for edits) before creating the actual form itself.

While I've suggested using XML as the base language for the form creation, it may also be possible to implement using XSLT as a tranformational language from form structure to form creation. Taking such an approach would need to consider certain aspects such as counting columns (to set colspans correctly), as well as how various elements, such as radio button sets, might span several rows or columns, and be contained within the same row as another element or elements.

Here is a potential XML outline of a form (that could be generated by the phase 2 page and then fed into the form creator itself, as well as retained in file form for future editing):

  

Gustafsj 13:48, 19 November 2007 (CST)