previo | siguiente

Goal: Forms should be templated


The templating system provides a form processing engine that allows for the specification of forms, their rendering by template or "by hand", and which provides state information to simplify form processing.

OpenACS provides a further, simplified Tcl procedure which "wraps" the templated form builder, named ad_form. Newcomers to OpenACS should concentrate on learning to use this procedure.

Form processing is conceptually divided into three states:

  • The data request state. In this state, the form builder renders a form, and returns it the user's browser in response to an HTTP request. The user fills in the required fields and submits the form.ad_form allows for the declaration of various blocks of code to be executed when form builder in the data request state.

  • Invalid state. When a form is submitted, its fields are validated according to their declared datatypes. In addition, the programmer can specify a validation block that does more complex checking (for instance to guarantee that the ending date of an event is later than the starting date).

  • Valid form submission state. After verification, the form may be processed, which usually involved inserting data from the form into the database.

ad_form also does key management for acs_objects. It optionally generates the object_id key automatically, and uses it along with the basic state information enumerated above to determine various code blocks to execute (the next slide contains an example). It pre-generates the key to provide basic multi-click protection, and signs it with an encrytped value to make it very difficult for a remote program to generate HTTP POST requests that look valid to the form builder.