Index: openacs-4/packages/acs-lang/tcl/lang-widget-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-lang/tcl/lang-widget-procs.tcl,v diff -u -r1.10 -r1.10.2.1 --- openacs-4/packages/acs-lang/tcl/lang-widget-procs.tcl 24 Apr 2018 14:28:55 -0000 1.10 +++ openacs-4/packages/acs-lang/tcl/lang-widget-procs.tcl 30 Nov 2023 15:13:27 -0000 1.10.2.1 @@ -24,13 +24,12 @@ 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(values)] } { template::util::list_to_lookup $element(values) values } - array set attributes $tag_attributes if { $element(mode) ne "edit" } { set selected_list [list] Index: openacs-4/packages/acs-templating/tcl/date-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/date-procs.tcl,v diff -u -r1.63.2.22 -r1.63.2.23 --- openacs-4/packages/acs-templating/tcl/date-procs.tcl 27 Oct 2023 11:08:51 -0000 1.63.2.22 +++ openacs-4/packages/acs-templating/tcl/date-procs.tcl 30 Nov 2023 15:13:27 -0000 1.63.2.23 @@ -1104,12 +1104,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 "\n" if { ! [info exists element(format)] } { @@ -1651,17 +1648,9 @@ } { upvar $element_reference element - set attributes [dict create] + set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] - # attributes supplied via -html switch - if { [info exists element(html)] } { - dict set attributes {*}$element(html) - } - - if {[llength $tag_attributes] > 0} { - dict set attributes {*}$tag_attributes - } - # Add fallback pattern attribute. Note that this pattern won't # account for leap years or invalid days of the month. We leave # this fine-graned validation to the server-side for now. @@ -1791,17 +1780,9 @@ } { upvar $element_reference element - set attributes [dict create] + set attributes \ + [::template::widget::merge_tag_attributes element $tag_attributes] - # attributes supplied via -html switch - if { [info exists element(html)] } { - dict set attributes {*}$element(html) - } - - if {[llength $tag_attributes] > 0} { - dict set attributes {*}$tag_attributes - } - # Add fallback pattern attribute (HH:MM:SS) dict set attributes pattern {(2[0-4]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]} Index: openacs-4/packages/acs-templating/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/form-procs.tcl,v diff -u -r1.59.2.7 -r1.59.2.8 --- openacs-4/packages/acs-templating/tcl/form-procs.tcl 29 Mar 2023 13:23:43 -0000 1.59.2.7 +++ openacs-4/packages/acs-templating/tcl/form-procs.tcl 30 Nov 2023 15:13:27 -0000 1.59.2.8 @@ -549,14 +549,14 @@ } } - # get any additional attributes developer specified to include in form tag - if { [info exists properties(html)] } { - array set attributes $properties(html) - } + # + # Get any additional attributes developer specified to include in + # the form tag and merge them with attributes specified by + # designer in the formtemplate tag. + # + array set attributes \ + [::template::widget::merge_tag_attributes properties $tag_attributes] - # add on or replace with attributes specified by designer in formtemplate tag - array set attributes $tag_attributes - # set the form to point back to itself if action is not specified if { ! [info exists properties(action)] } { set properties(action) [ns_conn url] Index: openacs-4/packages/acs-templating/tcl/richtext-or-file-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/richtext-or-file-procs.tcl,v diff -u -r1.13.2.1 -r1.13.2.2 --- openacs-4/packages/acs-templating/tcl/richtext-or-file-procs.tcl 13 Jan 2020 16:30:28 -0000 1.13.2.1 +++ openacs-4/packages/acs-templating/tcl/richtext-or-file-procs.tcl 30 Nov 2023 15:13:28 -0000 1.13.2.2 @@ -249,12 +249,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 { [info exists element(value)] } { set storage_type [template::util::richtext_or_file::get_property storage_type $element(value)] set mime_type [template::util::richtext_or_file::get_property mime_type $element(value)] Index: openacs-4/packages/acs-templating/tcl/richtext-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/richtext-procs.tcl,v diff -u -r1.66.2.11 -r1.66.2.12 --- openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 29 Aug 2022 14:17:24 -0000 1.66.2.11 +++ openacs-4/packages/acs-templating/tcl/richtext-procs.tcl 30 Nov 2023 15:13:28 -0000 1.66.2.12 @@ -430,12 +430,9 @@ #ns_log notice "widget::richtext: richtext-options? [info exists element(options)] HTML? [info exists element(html)]" - 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 { [info exists element(value)] } { set contents [template::util::richtext::get_property contents $element(value)] set format [template::util::richtext::get_property format $element(value)] Index: openacs-4/packages/acs-templating/tcl/tab-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/tab-procs.tcl,v diff -u -r1.10.2.1 -r1.10.2.2 --- openacs-4/packages/acs-templating/tcl/tab-procs.tcl 17 Dec 2019 17:01:20 -0000 1.10.2.1 +++ openacs-4/packages/acs-templating/tcl/tab-procs.tcl 30 Nov 2023 15:13:28 -0000 1.10.2.2 @@ -25,12 +25,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 { !$element(current) } { set url $element(base_url) 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)]