Forum OpenACS Development: tcl newbie question: where does category_ids come from

I'm working on adding categories support to file-storage, and while figuring out how to add a category selection list to the file-add form, I stumbled across some code in 'project-manager' that did what I wanted, see below:

if {![empty_string_p [category_tree::get_mapped_trees $package_id]]} {
    ad_form -extend -form {
  {category_ids:integer(category),multiple,optional {label "Categories"}
      {html {size 7}} {value {}}
}

This works. No problem there. And I mostly get what's going on. However where does that 'category_ids' variable (?) come from?

'get_mapped_trees' does not seem to set it or return it. The only place where it seems to be set is in 'categories::get_categories' but that is called nowhere in my code (at least not that I'm aware of).

BTW: the example code in the package developers docu does not seem to give the desired result (the result from that code being an empty select box with a single character 'f' as label). Or I must have done some *really* stupid things while adapting the code for my case, but ...

I'd really appreciate some light on this issue.

Thanks in advance,
JvD

Collapse
Posted by Jeff Davis on
The trick is that the category widget looks up the information from the database. If you are mapping a new item values is empty otherwise it has [list $object_id $container_id] (well, actually that is deprecated -- they are supposed to be passed as attributes category_application_id and category_object_id now, but project manager uses the old form).

Look at template::widget::category for the gory details.

You could also look at lars-blogger for a somewhat higher level interface which handles creating multiple form elements if you have multiple trees mapped.

Thanks ... I'm getting the picture. Talking about side-effects ... :-)