Forum OpenACS Q&A: Response to select option lists

Posted by Tom Jackson on

Not quite related with this issue, but just as annoying is having a database field that can only have a few values. Usually this is supported with a check constraint. Recently, I decided to move all check constraint fields into foreign key constraints and have a small helper table. The table holds the small integer primary key, a short description of the value and usually a boolean indicating that the entry is useable/displayable.

Then in the ACS templating system, I select from this table to create a multirow datasource. On the adp template page, I use code like this (sorry if this doesn't make through the email):

<multiple name=mychoices> <option value="@mychoices.choice_id@" <if @curval@ eq @mychoices.choice_id@>selected</if>>@mychoices.description@</option> </multiple>

If you need a default set even for new insert selects, I guess a separate column indicating a default would help.