[freeside-commits] freeside/httemplate/edit prospect_main.html, 1.1, 1.2
Ivan,,,
ivan at wavetail.420.am
Wed Dec 30 18:20:35 PST 2009
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail.420.am:/tmp/cvs-serv16477/httemplate/edit
Modified Files:
prospect_main.html
Log Message:
prospecting: proper contact error handling when you add a prospect
Index: prospect_main.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/prospect_main.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- prospect_main.html 28 Dec 2009 19:18:19 -0000 1.1
+++ prospect_main.html 31 Dec 2009 02:20:33 -0000 1.2
@@ -18,11 +18,16 @@
{ 'field' => 'contactnum',
'type' => 'contact',
'colspan' => 6,
- #actually o2m, but this seems to be working for edit so far
- 'm2name_table' => 'contact',
- 'm2name_namecol' => 'contactnum',
- 'm2_label' => 'Contact',
- 'm2_error_callback' => sub { my($cgi, $object) = @_; (); }, #XXX
+ ##actually o2m, but this seems to be working for edit so far
+ #'m2name_table' => 'contact',
+ #'m2name_namecol' => 'contactnum',
+ #'m2_label' => 'Contact',
+ #'m2_error_callback' => $m2_error_callback,
+
+ 'o2m_table' => 'contact',
+ 'm2_label' => 'Contact',
+ 'm2_error_callback' => $m2_error_callback,
+
},
{ 'field' => 'locationnum',
'type' => 'select-cust_location',
@@ -78,6 +83,33 @@
$prospect_main->set('locationnum', $locationnum);
};
+my $m2_error_callback = sub {
+ my($cgi, $object) = @_;
+
+ #process_o2m fields in process/prospect_main.html
+ my @fields = qw( first last title comment );
+ my @gfields = ( '', map "_$_", @fields );
+
+ map {
+ if ( /^contactnum(\d+)$/ ) {
+ my $num = $1;
+ if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
+ my $x = new FS::contact {
+ 'contactnum' => $cgi->param("contactnum$num"),
+ map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields,
+ };
+ use Data::Dumper; warn Dumper $x;
+ $x;
+ } else {
+ ();
+ }
+ } else {
+ ();
+ }
+ }
+ $cgi->param;
+};
+
my @agentnums = $FS::CurrentUser::CurrentUser->agentnums;
</%init>
More information about the freeside-commits
mailing list