fix silly bug sizing username field when adding an account (and username max is not...
[freeside.git] / httemplate / edit / svc_acct.cgi
index 4420bb6..57227d4 100755 (executable)
@@ -35,8 +35,6 @@ if ( $cgi->param('error') ) {
 
   } else { #adding
 
-    $svc_acct = new FS::svc_acct({}); 
-
     foreach $_ (split(/-/,$query)) {
       $pkgnum=$1 if /^pkgnum(\d+)$/;
       $svcpart=$1 if /^svcpart(\d+)$/;
@@ -44,6 +42,8 @@ if ( $cgi->param('error') ) {
     $part_svc = qsearchs( 'part_svc', { 'svcpart' => $svcpart } );
     die "No part_svc entry for svcpart $svcpart!" unless $part_svc;
 
+    $svc_acct = new FS::svc_acct({svcpart => $svcpart}); 
+
     $svcnum='';
 
     #set gecos
@@ -97,7 +97,7 @@ if ( $svc_acct->_password ) {
 }
 
 my $ulen = $conf->config('usernamemax')
-           || $svc_acct->dbdef_table->column('username')->length;
+           || dbdef->table('svc_acct')->column('username')->length;
 my $ulen2 = $ulen+2;
 
 my $pmax = $conf->config('passwordmax') || 8;
@@ -281,6 +281,14 @@ if ( $part_svc->part_svc_column('usergroup')->columnflag eq "F" ) {
 }
 print '</TD></TR>';
 
+foreach my $field ($svc_acct->virtual_fields) {
+  if ( $part_svc->part_svc_column($field)->columnflag ne 'F' ) {
+    # If the flag is X, it won't even show up in $svc_acct->virtual_fields.
+    print $svc_acct->pvf($field)->widget('HTML', 'edit', 
+        $svc_acct->getfield($field));
+  }
+}
+  
 #submit
 print qq!</TABLE><BR><INPUT TYPE="submit" VALUE="Submit">!;