On Sunday, February 06, 2011 03:05:54 am Bill Karwin wrote: > On Jan 28, 2011, at 1:26 AM, Martijn Korse wrote: > > It would be great if i could create a Form and then say: > > validate it and then insert it into the database (or update the data), > > without having to write the code over and over again. > > Right, this has been the quest of user-interface developers since > before you were born. > > In general, you can do this only if your form and your database table > are trivial. For example, no multi-value form fields, no multi-value > data elements, and form fields have a one-to-one mapping to database > columns with the same data types and same names, etc. This is almost > never true, unless you're only developing a demo. > > Form processing is complex because information is complex. There is > no form processing that is as simple as you describe, while also > supporting the range of options that developers need.
In general, I agree with what you are saying, Bill, but with the projects that I work on recently, at least half of the forms that I make are very simple one-to-one, form-to-database mapping. For example, user account creation: username, password, firstname, surname, phone number, birthday, etc. The only "oddball" is the id which would be automatically generated by the db. Perhaps what would be useful is for Zend_Tool to output skeleton code for a form using a db table to determine what fields are needed, etc. It would be a nice starting point, from which you could modify to suit your requirements. Of course there are bigger issues and features to work on. Though, in the future, that would be nice to have.
