% # OR
% # 'redirect' => 'view/table.cgi?', # value of primary key is appended
% #
+% # 'error_redirect' => popurl(2).'edit/table.cgi?', #query string appended
+% #
% # 'edit_ext' => 'html', #defaults to 'html', you might want 'cgi' while the
% # #naming is still inconsistent
% #
+% # 'copy_on_empty' => [ 'old_field_name', 'another_old_field', ... ],
+% #
+% # 'clear_on_error' => [ 'form_field1', 'form_field2', ... ],
+% #
% # 'process_m2m' => { 'link_table' => 'link_table_name',
% # 'target_table' => 'target_table_name',
% # },
% } @$fields
% } );
%
+% if ($old && exists($opt{'copy_on_empty'})) {
+% foreach my $field (@{$opt{'copy_on_empty'}}) {
+% $new->set($field, $old->get($field))
+% unless scalar($cgi->param($field));
+% }
+% }
+%
% my $error;
% if ( $pkeyvalue ) {
% $error = $new->replace($old);
%
% if ( $error ) {
% $cgi->param('error', $error);
+% if (scalar(@{$opt{'clear_on_error'}})) {
+% foreach my $field (@{$opt{'clear_on_error'}}) {
+% $cgi->param($field, '')
+% }
+% }
% my $edit_ext = $opt{'edit_ext'} || 'html';
-% print $cgi->redirect(popurl(2). "$table.$edit_ext?". $cgi->query_string );
+% my $url = $opt{'error_redirect'} || popurl(2)."$table.$edit_ext?";
+% print $cgi->redirect($url. $cgi->query_string );
% } elsif ( $opt{'redirect'} ) {
% print $cgi->redirect( $opt{'redirect'}. $pkeyvalue );
% } else {