X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Felements%2Fprocess.html;h=e24f3f6813a05e0ae0f9c73dda6d82afe2c4c24c;hb=03ceab71dad1e5eb366865d304e5e459cc905ce4;hp=6f271ee29a33b8a08d8e040d67050befb6326faf;hpb=e4fc461dd93181e8199d5cc5e2de2a11732b1bfd;p=freeside.git diff --git a/httemplate/edit/process/elements/process.html b/httemplate/edit/process/elements/process.html index 6f271ee29..e24f3f681 100644 --- a/httemplate/edit/process/elements/process.html +++ b/httemplate/edit/process/elements/process.html @@ -18,6 +18,7 @@ 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) @@ -33,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', @@ -54,13 +56,17 @@ Example: }, + 'process_o2m' => { 'table' => table_name', + 'num_col' => 'column', #if column name is different in + #link_table than source_table + }, #checks CGI params and whatever else before much else runs #return an error string or empty for no error 'precheck_callback' => sub { my( $cgi ) = @_; }, #supplies arguments to insert() and replace() - # for use with tables that are FS::option_Common + # for use with tables that are FS::option_Common (among other things) 'args_callback' => sub { my( $cgi, $object ) = @_; }, 'debug' => 1, #turns on debugging output @@ -176,6 +182,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} @@ -184,13 +197,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 = (); @@ -253,6 +259,28 @@ if ( !$error && $opt{'process_m2name'} ) { } +if ( !$error && $opt{'process_o2m'} ) { + + my @process_o2m = ref($opt{'process_o2m'}) eq 'ARRAY' + ? @{ $opt{'process_o2m'} } + : ( $opt{'process_o2m'} ); + + + foreach my $process_o2m (@process_o2m) { + + if ( $opt{'debug'} ) { + warn "$me processing o2m:\n". Dumper( %{ $process_o2m }, + 'params' => scalar($cgi->Vars), + ); + } + + $error = $new->process_o2m( %{ $process_o2m }, + 'params' => scalar($cgi->Vars), + ); + } + +} + if ( $error ) { $cgi->param('error', $error);