Forum OpenACS Development: Re: Retrieving ",multiple" from ad_form in widget proc

Collapse
Posted by Dave Bauer on
Multiple is ad_form only. It is not an option to template::element::create.

The multiple flag basically tells if you use get_value or get_values in the internal ad_form code.

Luckily template::element::create takes an arbitraty set of arguments -name value and adds them to the element definition. In this way you can create widgets that accept any arbitrary parameters.

To fix this you'd need to pass the multiple designation through to template::element create.

Based on this simple analysis it seems reasonble, but I haven't reviewed if it would affect any existing widgets to have the extra parameter. I think it would be ignored as long as no widgets are not expecting a multiple flag for some other reason.

Collapse
Posted by Malte Sussdorff on
Hi Dave, thanks a lot for the explanation. I managed to get this done by only changing a single line:

Index: acs-tcl/tcl/form-processing-procs.tcl
===================================================================
--- acs-tcl/tcl/form-processing-procs.tcl (revision 462)
+++ acs-tcl/tcl/form-processing-procs.tcl (working copy)
@@ -809,6 +809,7 @@
if { $af_element_parameters($element_name:$flag) ne "" } {
return -code error "element $element_name: $flag attribute can not have a parameter"
}
+ lappend form_command "-$flag"
}

nospell -

It would be great to see this added to the toolkit, especially as we could get away with a lot of code that tries to figure out if something is multiple or not in the widget-procs.tcl But who knows, maybe there is some code written somewhere that relies on multiple not being set in the element create, so I leave this to the OCT to decide whether to pick it up or not.

Thanks again for the outline and hints.