Index: openacs-4/packages/acs-tcl/tcl/form-processing-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/form-processing-procs.tcl,v diff -u -r1.66.2.5 -r1.66.2.6 --- openacs-4/packages/acs-tcl/tcl/form-processing-procs.tcl 25 May 2016 14:49:17 -0000 1.66.2.5 +++ openacs-4/packages/acs-tcl/tcl/form-processing-procs.tcl 28 May 2016 13:28:44 -0000 1.66.2.6 @@ -789,31 +789,33 @@ # :array and :sign flags in exported variables. if { [info exists export] } { foreach value $export { + set has_value_p [expr {[llength $value] >= 2}] lassign $value name value + + # recognize supported flags lassign [split $name ":"] name mode set modes [split $mode ,] - # recognize supported flags + + # verify variable existance and nature + set var_exists_p [uplevel [list info exists $name]] + set is_array_p [uplevel [list array exists $name]] + + # arrays are automatically recognized, even if not specified + set array_p [expr {$is_array_p || "array" in $modes}] set sign_p [expr {"sign" in $modes}] - set array_p [expr {"array" in $modes}] set multiple_p [expr {"multiple" in $modes}] - set is_array_p [uplevel [list array exists $name]] - # var is array and will be exported as such even if not said explicitly - if {$is_array_p} {set array_p t} - set is_var_p [expr {!$is_array_p && [uplevel [list info exists $name]]}] if {$array_p} { - if {$is_var_p} { - error "variable \"$name\" should be an array" - } - # no explicit value... - if {$value eq ""} { - # ...take it from caller stack... + # no explicit value: + if {!$has_value_p} { + # if array in caller stack exists, get its value from there if {$is_array_p} { set value [uplevel [list array get $name]] - # ...or ignore this field. - } else { - continue - } + # else, if a variable exists but it's not an array, throw error (as in export_vars) + } elseif {$var_exists_p} { + error "variable \"$name\" should be an array" + # else, just ignore this export + } else {continue} } # arrays generate one hidden formfield for each key foreach {key val} $value { @@ -830,15 +832,13 @@ } } } else { - # no explicit value... - if {$value eq ""} { - # ...take it from caller stack... - if {$is_var_p} { + # no explicit value: + if {!$has_value_p} { + # if variable in caller stack exists, get its value from there + if {$var_exists_p} { set value [uplevel [list set $name]] - # ...or ignore this field. - } else { - continue - } + # else, just ignore this export + } else {continue} } else { # # substitute only the explicitly specified value