Forum OpenACS Q&A: Re: Question on ad_form and select options

Collapse
Posted by Claudio Pasolini on
Hi Nick,

your code example contains two errors.

You can use the -on_request block to populate the form's elements, but you should put the definition of all the elements (in your example category_id is not defined ) under -form.

To populate a selection box you have to provide two values, the first being a description and the second being the corresponding id. So you have to supply category_description and category_id to set up your foo_options.

Actually there is no need, for the sake of this example, of a -request_block: simply put this element definition under -form and you are done:

{category_id:text(select)
{label "Which Category"}
{options [db_list_of_lists foo_option_list "select category_description, category_id from categories" ]}
}

A word of caution. If you were using the categories table of the categories package you should join the categories table with category_translations to get the category description.

Collapse
Posted by Nick Kokkos on
Thank you Claudio!
I am just learning the ropes here and was confused. Also, the categories table I use has nothing to do with the categories package. It's just a simple table with no id. That's where my problem was. Thanks again!