Generic form handler for static data files
Posted: Fri Nov 10, 2006 5:01 am
Guys,
I sure this must have been answered before but I can't find it.
I have a number of tables in my MySQL database that I need to maintain.
Mostly these tables are static data (VAT codes, Exchange Rates, Shipping methods etc..) and have not referential integrity to other tables (occassionaly though they will - eg. Campaign Codes are assigned to Media codes in in a 1:many relationship)
I can build a generic form builder by grabbing "Show fields from $table" and parsing the field name and data type/length to build the correct form field type and where necessary pop ups for date selectors etc.
How would you control additional validation required
Not Null is easy enough if the database has been set up correctly
How about
Must be positive value
although a string field on the form and in the database, convention says it should be (0-9) only
Value relates to another table/field and needs a SELECT OPTION drop down list (my current provider does not allow me to turn on referential integrity)
The two thoughts I have had are an XML file holding the additional valiation details or a table in the database to hold exceptions rules
Am I missing a trick that would make life easier?
Obiron
P.S. If it makes any difference I am using LAMP and will be doing lots of work with Ajax for real-time validation of data.
I sure this must have been answered before but I can't find it.
I have a number of tables in my MySQL database that I need to maintain.
Mostly these tables are static data (VAT codes, Exchange Rates, Shipping methods etc..) and have not referential integrity to other tables (occassionaly though they will - eg. Campaign Codes are assigned to Media codes in in a 1:many relationship)
I can build a generic form builder by grabbing "Show fields from $table" and parsing the field name and data type/length to build the correct form field type and where necessary pop ups for date selectors etc.
How would you control additional validation required
Not Null is easy enough if the database has been set up correctly
How about
Must be positive value
although a string field on the form and in the database, convention says it should be (0-9) only
Value relates to another table/field and needs a SELECT OPTION drop down list (my current provider does not allow me to turn on referential integrity)
The two thoughts I have had are an XML file holding the additional valiation details or a table in the database to hold exceptions rules
Am I missing a trick that would make life easier?
Obiron
P.S. If it makes any difference I am using LAMP and will be doing lots of work with Ajax for real-time validation of data.