[freeside-commits] freeside/httemplate/edit/process/elements process.html, 1.13, 1.14
Ivan,,,
ivan at wavetail.420.am
Tue Apr 15 06:42:43 PDT 2008
- Previous message: [freeside-commits] freeside/httemplate/edit/process part_pkg.cgi, 1.30, 1.31
- Next message: [freeside-commits] freeside/httemplate/elements select-agent_types.html, NONE, 1.1 select-taxproduct.html, 1.1, 1.2 selectlayers.html, 1.2, 1.3 tr-input-text.html, 1.3, 1.4 tr-part_pkg_freq.html, 1.1, 1.2 tr-pkg_svc.html, NONE, 1.1 tr-select-agent_types.html, NONE, 1.1 tr-title.html, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/edit/process/elements
In directory wavetail.420.am:/tmp/cvs-serv418/edit/process/elements
Modified Files:
process.html
Log Message:
new package editor
Index: process.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/process/elements/process.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- process.html 6 Apr 2008 16:12:46 -0000 1.13
+++ process.html 15 Apr 2008 13:42:40 -0000 1.14
@@ -32,8 +32,13 @@
'clear_on_error' => [ 'form_field1', 'form_field2', ... ],
+ #pass an arrayref of hashrefs for multiple m2ms or m2names
+
'process_m2m' => { 'link_table' => 'link_table_name',
'target_table' => 'target_table_name',
+ #optional (see m2m_Common::process_m2m), if not specified
+ # all CGI params will be passed)
+ 'params' =>
},
'process_m2name' => { 'link_table' => 'link_table_name',
'link_static' => { 'column' => 'value' },
@@ -49,6 +54,10 @@
},
+ #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
'args_callback' => sub { my( $cgi, $object ) = @_; },
@@ -107,8 +116,8 @@
<% $cgi->redirect( $opt{'redirect'}. $pkeyvalue ) %>
%
%} else {
-%
-<% $cgi->redirect( popurl(3). ($opt{viewall_dir}||'search'). "/$table.html" ) %>
+% my $ext = $opt{'viewall_ext'} || 'html';
+<% $cgi->redirect( popurl(3). ($opt{viewall_dir}||'search'). "/$table.$ext" ) %>
%}
<%once>
@@ -121,6 +130,11 @@
my $curuser = $FS::CurrentUser::CurrentUser;
+my $error = '';
+if ( $opt{'precheck_callback'} ) {
+ $error = &{ $opt{'precheck_callback'} }( $cgi );
+}
+
#false laziness w/edit.html
my $table = $opt{'table'};
my $class = "FS::$table";
@@ -146,7 +160,7 @@
}
my %hash =
- map { my @entry = ( $_ => $cgi->param($_) );
+ map { my @entry = ( $_ => scalar($cgi->param($_)) );
$opt{'value_callback'} ? ( $_ => &{ $opt{'value_callback'} }( @entry ))
: ( @entry )
} @$fields;
@@ -168,7 +182,7 @@
}
}
-my $error = $new->check;
+$error ||= $new->check;
my @args = ();
if ( !$error && $opt{'args_callback'} ) {
@@ -192,28 +206,42 @@
if ( !$error && $opt{'process_m2m'} ) {
- if ( $opt{'debug'} ) {
- warn "$me processing m2m:\n". Dumper( %{ $opt{'process_m2m'} },
- 'params' => scalar($cgi->Vars),
- );
+ my @process_m2m = ref($opt{'process_m2m'}) eq 'ARRAY'
+ ? @{ $opt{'process_m2m'} }
+ : ( $opt{'process_m2m'} );
+
+ foreach my $process_m2m (@process_m2m) {
+
+ $process_m2m->{'params'} ||= scalar($cgi->Vars);
+
+ warn "$me processing m2m:\n". Dumper( %$process_m2m )
+ if $opt{'debug'};
+
+ $error = $new->process_m2m( %$process_m2m );
}
- $error = $new->process_m2m( %{ $opt{'process_m2m'} },
- 'params' => scalar($cgi->Vars),
- );
}
if ( !$error && $opt{'process_m2name'} ) {
- if ( $opt{'debug'} ) {
- warn "$me processing m2name:\n". Dumper( %{ $opt{'process_m2name'} },
- 'params' => scalar($cgi->Vars),
- );
+ my @process_m2name = ref($opt{'process_m2name'}) eq 'ARRAY'
+ ? @{ $opt{'process_m2name'} }
+ : ( $opt{'process_m2name'} );
+
+
+ foreach my $process_m2name (@process_m2name) {
+
+ if ( $opt{'debug'} ) {
+ warn "$me processing m2name:\n". Dumper( %{ $process_m2name },
+ 'params' => scalar($cgi->Vars),
+ );
+ }
+
+ $error = $new->process_m2name( %{ $process_m2name },
+ 'params' => scalar($cgi->Vars),
+ );
}
- $error = $new->process_m2name( %{ $opt{'process_m2name'} },
- 'params' => scalar($cgi->Vars),
- );
}
- Previous message: [freeside-commits] freeside/httemplate/edit/process part_pkg.cgi, 1.30, 1.31
- Next message: [freeside-commits] freeside/httemplate/elements select-agent_types.html, NONE, 1.1 select-taxproduct.html, 1.1, 1.2 selectlayers.html, 1.2, 1.3 tr-input-text.html, 1.3, 1.4 tr-part_pkg_freq.html, 1.1, 1.2 tr-pkg_svc.html, NONE, 1.1 tr-select-agent_types.html, NONE, 1.1 tr-title.html, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list