Index: openacs-4/packages/acs-templating/tcl/widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/widget-procs.tcl,v diff -u -r1.63.2.23 -r1.63.2.24 --- openacs-4/packages/acs-templating/tcl/widget-procs.tcl 30 Nov 2023 14:14:54 -0000 1.63.2.23 +++ openacs-4/packages/acs-templating/tcl/widget-procs.tcl 30 Nov 2023 15:13:28 -0000 1.63.2.24 @@ -19,6 +19,27 @@ namespace eval template::data {} namespace eval template::data::transform {} +ad_proc -private template::widget::merge_tag_attributes { + element_reference + tag_attributes +} { + Consolitates the logics to compute the final tag attributes by + merging those explicitly supplied and those in the element + definition. + + @return dict +} { + upvar $element_reference element + + if { [info exists element(html)] } { + foreach {key value} $element(html) { + dict lappend tag_attributes $key {*}$value + } + } + + return $tag_attributes +} + ad_proc -public template::widget {} { The template::widget namespace contains the code for the various input widgets. @@ -80,7 +101,7 @@ if { ![info exists element(options)] } { # initial submission or no data (no options): a text box - set output [input text element $tag_attributes] + set output [input text element $tag_attributes } else { @@ -276,10 +297,8 @@ upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } - array set attributes $tag_attributes + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] if { [info exists element(value)] } { set value $element(value) @@ -384,12 +403,9 @@ upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] - array set attributes $tag_attributes - if { ( $type eq "checkbox" || $type eq "radio" ) && [info exists element(value)] } { @@ -484,7 +500,8 @@ upvar $element_reference element - array set attributes $tag_attributes + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] # # If the multiple flag is set for the element, we allow more than one file @@ -572,9 +589,10 @@ # always ignore value for submit widget set element(value) $element(label) - - return [input submit element \ - [dict lappend tag_attributes class prevent-double-click]] + + dict lappend tag_attributes class prevent-double-click + + return [input submit element $tag_attributes] } ad_proc -public template::widget::attachment { @@ -758,12 +776,9 @@ upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] - array set attributes $tag_attributes - return [template::widget::menu \ $element(name) $element(options) $element(values) attributes $element(mode)] } @@ -782,12 +797,9 @@ upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] - array set attributes $tag_attributes - set attributes(multiple) {} # Determine the size automatically for a multiselect @@ -896,12 +908,9 @@ upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] - array set attributes $tag_attributes - set output {} if { [info exists element(history)] } { @@ -938,18 +947,15 @@ } { upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] if { [info exists element(value)] } { set value $element(value) } else { set value {} } - array set attributes $tag_attributes - set output "" set options $element(options) set count 0 @@ -1075,11 +1081,9 @@ } { upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } - array set attributes $tag_attributes + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] if { [info exists element(value)] } { set select [template::util::select_text::get_property select_value $element(value)] @@ -1188,11 +1192,9 @@ @error } { upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } - array set attributes $tag_attributes + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] if { [info exists element(value)] } { set radio [template::util::radio_text::get_property radio_value $element(value)] @@ -1314,11 +1316,9 @@ @error } { upvar $element_reference element - if { [info exists element(html)] } { - array set attributes $element(html) - } - array set attributes $tag_attributes + array set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] if { [info exists element(values)] } { set checkbox [template::util::checkbox_text::get_property checkbox_value $element(values)]