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 -r1.60 --- openacs-4/packages/acs-templating/tcl/form-procs.tcl 28 Dec 2018 11:24:10 -0000 1.59 +++ openacs-4/packages/acs-templating/tcl/form-procs.tcl 3 Sep 2024 15:37:35 -0000 1.60 @@ -18,11 +18,14 @@ namespace eval template {} namespace eval template::form {} -ad_proc -public form {command args} { +ad_proc -deprecated form {command args} { form is really template::form although when in the "template" namespace you may omit the template:: + DEPRECATED: no, you should not omit the namespace, and this proc + does not comply with OpenACS naming convention. + @see template::form @see template::element } - @@ -39,7 +42,6 @@ @see template::form::set_properties @see template::form::get_properties @see template::form::exists - @see template::form::export @see template::form::get_combined_values @see template::form::get_values @see template::form::get_elements @@ -174,7 +176,7 @@ if { [info exists opts(elements)] } { # strip carriage returns - regsub -all {\r} $opts(elements) {} element_data + regsub -all -- {\r} $opts(elements) {} element_data foreach element [split $element_data "\n"] { set element [string trim $element] @@ -229,26 +231,15 @@ # Otherwise, find out now - set formbutton {} - # If the form isn't being submitted at all, no button was clicked - if { $id ne [ns_queryget form:id] } { + if { ![ns_conn isconnected] || $id ne [ns_queryget form:id] } { return {} } # Search the submit form for the button - set form [ns_getform] + set formbutton [lindex [ns_set keys [ns_getform] "formbutton:*"] 0] + regsub {^formbutton:} $formbutton {} formbutton - if { $form ne "" } { - set size [ns_set size $form] - for { set i 0 } { $i < $size } { incr i } { - if { [string match "formbutton:*" [ns_set key $form $i]] } { - set formbutton [string range [ns_set key $form $i] [string length "formbutton:"] end] - break - } - } - } - return $formbutton } @@ -349,16 +340,15 @@ set file_stub [template::resource_path -type forms -style standard] } - # ensure that the style template has been compiled and is up-to-date - template::adp_init adp $file_stub - - # get result of template output procedure into __adp_output - # the only data source on which this template depends is the "elements" + # + # Ensure that the style template has been compiled and is + # up-to-date, and execute the result into __adp_output. The only + # data source on which this template depends is the "elements" # multirow data source. The output of this procedure will be # placed in __adp_output in this stack frame. + # + [template::adp_init adp $file_stub] - template::code::adp::$file_stub - return $__adp_output } @@ -494,13 +484,13 @@ } if { [info exists form_properties(has_submit)] - && [template::util::is_true $form_properties(has_submit)] + && [string is true -strict $form_properties(has_submit)] } { set form_properties(edit_buttons) {} } if { [info exists form_properties(has_edit)] - && [template::util::is_true $form_properties(has_edit)] + && [string is true -strict $form_properties(has_edit)] } { set form_properties(display_buttons) {} } @@ -559,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] @@ -633,12 +623,11 @@ append output "$fieldset_legend" } - # Export variables specified by the export property as hidden - # formfields. (used e.g. by ad_form when specifying the -export - # flag) - if { [info exists form_properties(export)] } { + # Include exported variables created by ad_form when specifying + # the -export flag + if { [info exists form_properties(exported_vars)] } { append output {} - append output [uplevel #$level [subst {export_vars -form {$form_properties(export)}}]] + append output $form_properties(exported_vars) append output {} } @@ -867,11 +856,16 @@ } } -ad_proc -public template::form::export {} { +ad_proc -deprecated template::form::export {} { Generates hidden input tags for all values in a form submission. Typically used to create a confirmation page following an initial submission. + DEPRECATED: this proc has been superseded by export_vars, which + also offers additional features. + + @see export_vars + @return A string containing hidden input tags for inclusion in a form. } {