Forum OpenACS Development: ad_set_form_values bug?

Collapse
Posted by Jun Yamog on

Is this a bug on ad_set_form_values?

ad_set_form_values foo

if foo start with a "-" like "- bar". "- bar" is taken as a switch?

Invalid switch: "- bar"
    while executing
"ad_set_element_value__arg_parser"
    (procedure "ad_set_element_value" line 1)
    invoked from within
"ad_set_element_value -element $arg $value"
    (procedure "ad_set_form_values" line 5)
Collapse
Posted by Andrew Piskorski on
Probably yes. It is a common mistake when using Tcl's switch statement. To fix, simply add "--" in the switch command, like so:
switch -exact -another_option -- $my_variable
Collapse
Posted by Don Baccus on
It's not a switch statement that's causing the problem, it's the switch (-ified parameters) parser ...

But the fix is similar ... ad_set_form_values calls ad_set_element_value and should have a "--" separating the arg that names the element and the value.  I'll fix this and commit to the 4.6 branch today.

Collapse
Posted by Don Baccus on
I've fixed this (haven't committed yet, will soon) but all that does is uncover a bug in the form templating system's "element::set" procedure.  The value always gets set to "1" if there's a leading "-".

And of course the templating system has its own arg parser ... grrr ... I'll look into fixing this one tomorrow.