Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -r1.284.2.157 -r1.284.2.158 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 18 May 2021 20:23:46 -0000 1.284.2.157 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 28 Jun 2021 15:31:15 -0000 1.284.2.158 @@ -1302,6 +1302,11 @@ return $html } + FormField instproc reset_to_default args { + # + # We don't actually do anything here, but subclassess can overload it. + # + } ########################################################### # @@ -1683,6 +1688,16 @@ } } + CompoundField instproc reset_to_default args { + # + # We actually want to reset all the leaf components + # + ns_log debug "reset_to_default COMPOUND" + foreach f [:leaf_components] { + $f reset_to_default {*}$args + } + } + ########################################################### # # ::xowiki::formfield::submit_button @@ -2071,6 +2086,19 @@ } + file instproc reset_to_default args { + # + # Reset the value for form-fields of type "file" to avoid + # confusions in case of form validation error. A file-name might + # have been provided provided, but the file was not uploaded due + # to the validation error. If we would not reset the value, the + # provided name would cause an interpretation of an uploaded empty + # file. + # + ns_log debug "reset_to_default [:serialize]" + set :value "" + } + ########################################################### # # ::xowiki::formfield::import_archive Index: openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl,v diff -u -r1.368.2.90 -r1.368.2.91 --- openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 30 May 2021 18:52:03 -0000 1.368.2.90 +++ openacs-4/packages/xowiki/tcl/xowiki-www-procs.tcl 28 Jun 2021 15:31:15 -0000 1.368.2.91 @@ -1145,6 +1145,7 @@ :save_data \ -use_given_publish_date [expr {"_publish_date" in $field_names}] \ [::xo::cc form_parameter __object_name ""] $category_ids + # # The data might have references. Perform the rendering here to compute # the references instead on every view (which would be safer, but slower). This is @@ -2747,6 +2748,7 @@ } # + # Finally run the validator on the top-level fields # foreach f [concat $form_fields] { @@ -2789,17 +2791,10 @@ } else { :log validation_errors=$validation_errors # - # There were validation errors. Reset the value for form-fields - # of type "file" to avoid confusions, since a file-name was - # provided, but the file was not uploaded due to the validation - # error. If we would not reset the value, the provided name - # would cause an interpretation of an uploaded empty file. Maybe - # a new method "reset-to-default" would be a good idea. + # There were validation errors. Reset the value of form-fields. # foreach f $form_fields { - if {[$f type] eq "file"} { - $f set value "" - } + $f reset_to_default } }