![projects](images/title-projects.gif)
Forms PHP Class
Starting with the DHCP/DNS system I helped build in the Summer of 2005, we (the CS Department System's Staff) started putting all kinds of things into
MySQL to make our lives easier. We added user data, user disk usage broken down by supervisor, desk information, computer information, room and equipment
reservations, and, most recently, support for user management of e-mail whitelists. About the time I hit the third or fourth table
of MySQL data, it became apparent that I needed to build something to make it easy to interface with all this data.
My solution to the problem was a PHP class that displayed and validated forms. There were several PHP libraries available that did things similar to what I wanted, but nothing would do it all. The class has turned into one of the most useful pieces of software I've ever written. It currently includes the following features:
- Given a MySQL table, creates a form to add, edit, or delete entries from the table.
- Supports all standard HTML form elements along with arrays of checkboxes mapped to a single MySQL field, JavaScript auto-complete boxes, and JavaScript date chooser boxes.
- Validates data entered into the form based on the structure of the MySQL table optionally associated with the form and also based on anything else the user specifies, with some basic functionality built-in for checking data against various other tables.
- Inline error notification for each form element.
- JavaScript-based popup hints for each form field.
- A mass-adder subclass which can take any form and turn it into a mass-add form by specifying which fields to hold constant, which fields to increment and which field to use a key for incrementing.
- Every form field can be individually styled.
- For every form field created in HTML, there is an associated JavaScript object to allow dynamically changing the label, hint, visibility etc.
You can play with the demo version here.