Form Class
Posted: Sun Oct 08, 2006 9:27 am
Overview-
I'm looking to make a form class to automate the generation of forms to add,edit,and delete information from a database. I want to use the field names of the database to automate form creation. Also, as a side product I figured I might as well add a sub class to process the information. What this will do is enable someone to type in their code which will then create a form to add a new user, for example, based off how the table called "Table_name" is structured.
Here's what I'm thinking for the general structure..can someone shoot holes in it if I did something stupid,please?
Edit: Simply posting "looks good" will satisfy me.
Jcart | Changed to [code tags
Charles256 | : kicks Jcart : 
I'm looking to make a form class to automate the generation of forms to add,edit,and delete information from a database. I want to use the field names of the database to automate form creation. Also, as a side product I figured I might as well add a sub class to process the information. What this will do is enable someone to type in their code
Code: Select all
$form=new form("table_name","POST","Sign up!");
$form->add();Here's what I'm thinking for the general structure..can someone shoot holes in it if I did something stupid,please?
Edit: Simply posting "looks good" will satisfy me.
Code: Select all
Field Structure required=
Req_Display&Name_field&type_expected&datastructure_select&options.
Form Structure class
{
Get form structure from field names of mysql table
Spaces denoted by &, new areas denoted by _
First&Name_text should generate First Name<input type='text' name='First&Name' />
}
Add Record Class Extends Form Structure Class
{
Generate an empty form from using
The info gathered in the form structure class.
}
Edit Record Class Extends Form Structure Class
{
Use form structure information to build a drop down
With unique information from the form.
When dropdown is submitted
Use the id to pull all the information and build a form
Prepopulated with information from the database.
}
Delete Record Class Extends Form Structure Class
{
Same principle as edit record except you delete the record you select.
}
Process Form Extends Form Structure Class
{
Loop through every post element (authorized elements come from table structure)
Find expected data structure and do a check on the field.
If it fails store an error to be displayed when they get back to the page.
If it passes go back to the (add,edit,delete) and submit the information
In the appropriate manner.
}