Forum OpenACS Development: Lookup Tables with ad_form

Collapse
Posted by Alex Kroman on
I'm having a problem getting ad_form to highlight previously chosen values in a multiselect box. The code for the box looks like:

{brands:text(multiselect),multiple,optional
{values $brands}
{label "Brands"}
{options {{"--- TBD ---" ""} [db_list_of_lists get_brand "select name, ibr_brand_id from ibr_brand order by name"]}}
}

outside of the ad_form I have:

set brands [db_list_of_lists project_brands_query {}]

The query is returning the brands that should be selected in the same form as the get_brand query.

So what is the totally obvious thing that I am overlooking?

Collapse
Posted by Dave Bauer on
To set the select items in the list you just pass a list of the ids.

You should set it in a -new_request or -edit_request block of ad_form.

ie

-edit_request {
set brands [db_list selected_brands {}]
}

Collapse
Posted by Alex Kroman on
Thanks Dave!