Forum OpenACS Development: Re: ad_form all over the place?

Collapse
Posted by Don Baccus on
Although it might be thought that having input of content and editing handled by the same form/tcl page, in actual practice I doubt it would be generally helpful. Remembering maintainance of current code, it is much easier to track down bugs if pages have a single function.
Those of us using the form builder haven't found this to be true. Typically there are two differences between a form to edit data and to add new data
  • the database operations (insert vs. update) however when using the CR this can be masked - my CR ad_form pages generally have a single "on_submit" clause.
  • Data needs to be filled in from the DB in the edit case

For those cases where you do have to do different operations when adding new data vs. editing existing data, I think the two separate clauses "edit_data" and "new_data" are quite clear.

On the other hand, there are generally at least two things in common, and it is nice to not have to maintain two separate chunks of code for them

  • The form elements and layout itself - it is nice to be able to guarantee consistency
  • validation of data - it is crucial that data validation being semantically identical for pages that edit existing and add new data

The form builder paradigm encourages this code sharing, and ad_form simplifies the associated state management.