document viewall_ext
[freeside.git] / httemplate / edit / process / elements / process.html
index 7964dfa..5befdd3 100644 (file)
@@ -18,8 +18,10 @@ Example:
    ###
 
    'viewall_dir'  => '', #'search' or 'browse', defaults to 'search'
+   'viewall_ext'  => 'html', #'cgi' or 'html', defaults to 'html'
    OR
    'redirect'     => 'view/table.cgi?', # value of primary key is appended
+                                        # (string or coderef returning a string)
    OR
    'popup_reload' => 'Momentary success message', #will reload parent window
 
@@ -32,7 +34,8 @@ Example:
 
    'clear_on_error' => [ 'form_field1', 'form_field2', ... ],
 
-                    #pass an arrayref of hashrefs for multiple m2ms or m2names
+                  #pass an arrayref of hashrefs for multiple m2ms or m2names
+                  #be certain you incorporate m2m_Common if you see error: param
 
    'process_m2m' => { 'link_table'   => 'link_table_name',
                       'target_table' => 'target_table_name',
@@ -111,21 +114,29 @@ Example:
   </BODY>
   </HTML>
 
-%} elsif ( $opt{'redirect'} ) {
+%} else {
+%  
+%  $opt{'redirect'} = &{$opt{'redirect'}}($cgi, $new)
+%    if ref($opt{'redirect'}) eq 'CODE';
+%
+%  if ( $opt{'redirect'} ) {
 %
 <% $cgi->redirect( $opt{'redirect'}. $pkeyvalue ) %>
 %
-%} else { 
-%  my $ext = $opt{'viewall_ext'} || 'html';
+%  } else { 
+%
+%    my $ext = $opt{'viewall_ext'} || 'html';
+%
 <% $cgi->redirect( popurl(3). ($opt{viewall_dir}||'search'). "/$table.$ext" ) %>
+%
+%  }
+%
 %}
-<%once>
-
-  my $me = 'process.html:';
-
-</%once>
+%
 <%init>
 
+my $me = 'process.html:';
+
 my(%opt) = @_;
 
 my $curuser = $FS::CurrentUser::CurrentUser;
@@ -167,6 +178,13 @@ my %hash =
 
 my $new = $class->new( \%hash );
 
+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));
+  }
+}
+
 if ( $opt{'agent_virt'} ) {
   die "illegal agentnum"
     unless $curuser->agentnums_href->{$new->agentnum}
@@ -175,13 +193,6 @@ if ( $opt{'agent_virt'} ) {
            && $curuser->access_right($opt{'agent_null_right'});
 }
 
-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));
-  }
-}
-
 $error ||= $new->check;
 
 my @args = ();