Forum OpenACS Q&A: Response to "template:multirow create" for customizable fields

Esti,

You can't do template::multirow create the way you do, because the [join] command delivers all the column names as one argument (i.e., as one Tcl string).

You can either say something like:

eval "template::multirow create user_custom [join $custom_field_list " "]"

Or you can say

template::multirow create user_custom
foreach field $custom_field_list {
    template::multirow extend user_custom $field
}

With ad_page_contract, the whole intent of introducing ad_page_contract was to ensure that you explicitly enumerated all the variables you wanted, so you don't risk accidentally overriding some local variable that you happened to be using in the script, or other nasty business like that.

Instead, we introduced the :array feature, where you can get all the variables you want, but within a limited area of potential damage.

If you name your form variables

custom_vars.some_var
custom_vars.other_var
custom_vars.third_var

You can have an ad_page_contract saying:

ad_page_contract { ... } {
    custom_vars:array
}

And then you can access the values

$custom_vars(some_var)
$custom_vars(other_var)
$custom_vars(third_var)

If you want it to be a bit more strict, you can write a -validate block which checks against the query.

Hope this helps.