Web Forms and Validation

For the last year I have been working on a dynamic form engine. The idea is to define the form once and to use that definition to display the form, validate the form, redisplay the form with embedded error messages if needed and process the submission. The idea is to use as simple a definition method as possible so that an interface could be built through which forms could be built and saved into a database. So far I have this much done. The system allows one to construct a form definition, present the form and validate the form submission. It currently handles all HTML form elements, including select menus. My next challenge is customized formatting. At this point my engine gives you two options: present the form in a table (no thinking required) or get the raw elements that make up the form in an array and lay the form out yourself. My plan calls for display templates. The idea is to create an XML/XHTML template that dictates the layout of the form. Here's Simon Willison's approach: Easier form validation with PHP