Forum OpenACS Q&A: Response to select list populated from db and form templates

Using a select widget is fine if you don't expect to have many users. If you do, I would use something like the following which generates a text widget where the name can be entered:
template::element create person_form person_id
    -widget search
    -datatype search
    -label {Name}
    -search_query {
        select last_name||','||first_names, person_id
        from persons
        where last_name||','||first_names like :value} 
    -value $person_id
Note that :value is defined by the interface and must remain the same. The form will expect you to enter last,first in my example.

The page contract has {person_id {}} for this element/variable.

There is only one bug in this that I know of: If some part of the form doesn't validate, all -search datatype elements' numeric values are displayed instead of being translated back to the person's name via the -search_query. This datatype is a really cool, but the implementation is not quite there.

Note I use 'like' instead of =, which allows a user to type 'lastname%'. If the -search_query returns returns multiple rows, this widget presents a select box from them.