Index: openacs-4/packages/spreadsheet/tcl/form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/spreadsheet/tcl/form-procs.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/spreadsheet/tcl/form-procs.tcl 9 Mar 2011 17:54:10 -0000 1.16 +++ openacs-4/packages/spreadsheet/tcl/form-procs.tcl 26 Mar 2011 00:50:20 -0000 1.17 @@ -10,13 +10,13 @@ # main namespace vars: # __form_input_arr = array that contains existing form input and defaults, only one form can be posted at a time # __form_ids_list = list that contains existing form ids -# __form_ids_open_list = list that contains forms that are not closed +# __form_ids_open_list = list that contains ids of forms that are not closed # __form_ids_fieldset_open_list = list that contains form ids where a fieldset tag is open -# __form_arr contains forms built as strings by appending tags to strings, indexed by form id, for example __form_arr($id) -# __qf_arr contains last attribute values of tag, indexed by {tag}_attribute, __form_last_id is in __qf_arr(form_id) +# __form_arr contains an array of forms. Each form built as a string by appending tags, indexed by form id, for example __form_arr($id) +# __qf_arr contains last attribute values of a tag (for all forms), indexed by {tag}_attribute, __form_last_id is in __qf_arr(form_id) # a blank id passed in anything other than qf_form assumes the current (most recent used form_id) -# to fix: id for not form tag should not be same as form id. add an attribute -form_id for assigning tags to specific forms. +# to fix: id for nonform tag should not be same as form id. use an attribute "form_id" for assigning tags to specific forms. #use following to limit access to page requests via post.. to reduce vulnerability to url hack and insertion attacks from web: #if { [ad_conn method] != POST } { @@ -29,7 +29,7 @@ } { get inputs from form submission, quotes all input values. use ad_unquotehtml to unquote a value. } { - upvar $form_array_name __form_input_arr + upvar 1 $form_array_name __form_input_arr # get form variables passed with connection set __form [ns_getform] if { $__form eq "" } { @@ -68,14 +68,19 @@ } ad_proc -public qf_remember_attributes { + {arg1 "1"} } { - changes qf_* form building procs to use the previous attribute values used with the last tag of same type (input,select,button etc). + changes qf_* form building procs to use the previous attribute values used with the last tag of same type (input,select,button etc). passing anything other than 0 defaults to 1 (true). } { upvar __qf_remember_attributes __qf_remember_attributes - set __qf_remember_attributes 1 + if { $arg1 eq 0 } { + set __qf_remember_attributes 0 + } else { + set __qf_remember_attributes 1 + } } -ad_proc -public qf_open { +ad_proc -public qf_form { {arg1 ""} {arg2 ""} {arg3 ""} @@ -92,15 +97,16 @@ {arg14 ""} {arg15 ""} {arg16 ""} - } { initiates a form with form tag and supplied attributes. Returns an id. A clumsy url based id is provided if not passed (not recommended). } { # use upvar to set form content, set/change defaults # __qf_arr contains last attribute values of tag, indexed by {tag}_attribute, __form_last_id is in __qf_arr(form_id) - upvar __form_ids_list __form_ids_list, __form_arr __form_arr - upvar __form_ids_open_list __form_ids_open_list - upvar __qf_remember_attributes __qf_remember_attributes, __qf_arr __qf_arr + upvar 1 __form_ids_list __form_ids_list + upvar 1 __form_arr __form_arr + upvar 1 __form_ids_open_list __form_ids_open_list + upvar 1 __qf_remember_attributes __qf_remember_attributes + upvar 1 __qf_arr __qf_arr # if proc was passed a list of parameters, parse if { [llength $arg1] > 1 && [llength $arg2] == 0 } { @@ -121,18 +127,22 @@ if { $attribute_index > -1 } { set attributes_arr($attribute) $value lappend attributes_list $attribute + } elseif { $value eq "" } { + # ignore } else { - ns_log Error "qf_open: $attribute is not a valid attribute. invoke with attribute value pairs. Separate each with a space." + ns_log Error "qf_form: $attribute is not a valid attribute. invoke with attribute value pairs. Separate each with a space." } } if { ![info exists attributes_arr(method)] } { set attributes_arr(method) "post" } if { ![info exists __qf_remember_attributes] } { +ns_log Notice "qf_form L134: set __qf_remember_attributes 0" set __qf_remember_attributes 0 } if { ![info exists __form_ids_list] } { +ns_log Notice "qf_form L138: set __form_ids_list.." set __form_ids_list [list] } if { ![info exists __form_ids_open_list] } { @@ -147,8 +157,9 @@ } } # every form gets an id, if only to help identify it in debugging - if { ![info exists attributes_arr(id) || $attributes_arr(id) eq "" } { + if { ![info exists attributes_arr(id) ] || $attributes_arr(id) eq "" } { set attributes_arr(id) "[ad_conn url]-[llength $__form_ids_list]" +ns_log Notice "qf_form: generating form_id $attributes_arr(id)" } # prepare attributes to process @@ -163,14 +174,15 @@ set tag_html "