Index: openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl 8 Jun 2005 11:36:46 -0000 1.5 +++ openacs-4/packages/dynamic-types/tcl/dynamic-type-procs.tcl 7 Jul 2005 00:21:13 -0000 1.6 @@ -24,6 +24,8 @@ {-object_type:required} {-array:required} {-exclude_static:boolean} + {-dform implicit} + {-variables ""} } { Populates array with the data for the object specified. } { @@ -55,6 +57,43 @@ set columns [join $columns ", "] db_0or1row select_object {} -column_array local } + + dtype::form::metadata::widgets -object_type $object_type \ + -dform $dform \ + -exclude_static_p $exclude_static_p \ + -multirow widgets + + dtype::form::metadata::params -object_type $object_type \ + -dform $dform \ + -multirow params + + set widget_count [template::multirow size widgets] + set param_count [template::multirow size params] + + for {set w 1} {$w <= $widget_count} {incr w} { + template::multirow get widgets $w + + if {[lsearch -exact [list "select" "multiselect" "checkbox" "radio"] $widgets(widget)] > -1} { + + for {set p 1} {$p <= $param_count} {incr p} { + template::multirow get params $p + + if {$params(attribute_id) != $widgets(attribute_id) || $params(param) != "options"} { + continue; + } + + set options [dtype::form::parameter_value -parameter params -vars $variables] + set new_value "" + set old_value $local($widgets(attribute_name)) + foreach option $options { + if {[lsearch -exact $old_value [lindex $option 1]] > -1} { + lappend new_value [lindex $option 0] + } + } + set local($widgets(attribute_name)) [join $new_value ", "] + } + } + } } ad_proc -public dtype::create { Index: openacs-4/packages/dynamic-types/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dynamic-types/tcl/form-procs.tcl,v diff -u -N -r1.8 -r1.9 --- openacs-4/packages/dynamic-types/tcl/form-procs.tcl 5 Jun 2005 12:36:45 -0000 1.8 +++ openacs-4/packages/dynamic-types/tcl/form-procs.tcl 7 Jul 2005 00:21:13 -0000 1.9 @@ -43,6 +43,7 @@ {-cr_widget_options {}} {-exclude {}} {-exclude_static:boolean} + {-variables {}} } { Adds the elements of the specified object types dynamic form and all of its supertypes dynamic forms to the specified template form. @@ -122,7 +123,8 @@ -cr_widget $cr_widget \ -cr_widget_options $cr_widget_options \ -exclude_static_p $exclude_static_p \ - -exclude $exclude + -exclude $exclude \ + -variables $variables } } @@ -487,6 +489,7 @@ {-cr_widget_options {}} {-exclude_static_p 0} {-exclude {}} + {-variables {}} } { Adds the elements of the specified or implicit object form to the specified template form. @@ -580,7 +583,7 @@ break; } - set value [dtype::form::parameter_value -parameter params] + set value [dtype::form::parameter_value -parameter params -vars $variables] # determine if the parameter value is null switch $params(param_type) { @@ -593,7 +596,7 @@ } } - if {!$null_value_p} { + if {!$null_value_p || $params(param) == "options"} { if {[template::util::is_true $params(is_html)]} { lappend html_options $params(param) lappend html_options $value @@ -754,11 +757,14 @@ ad_proc -private dtype::form::parameter_value { {-object_type ""} {-parameter:required} + {-vars:required} } { Calculates and returns the current value for the supplied parameter array based on its type, source and default_value attributes. + Provide variables to tcl-procs by \$variables(--name--) } { upvar $parameter param + array set variables $vars set value "" set attribute_id $param(attribute_id)