RT# 81126 - IP address field now shows required when required, IP address and Radius...
authorChristopher Burger <burgerc@freeside.biz>
Wed, 28 Nov 2018 13:55:29 +0000 (08:55 -0500)
committerChristopher Burger <burgerc@freeside.biz>
Wed, 28 Nov 2018 15:55:24 +0000 (10:55 -0500)
Conflicts:
FS/FS/svc_broadband.pm

FS/FS/svc_broadband.pm
httemplate/edit/elements/edit.html
httemplate/edit/process/elements/process.html
httemplate/edit/svc_broadband.cgi

index 9cd0859..45c6b11 100755 (executable)
@@ -96,6 +96,8 @@ points to.  You can ask the object for a copy with the I<hash> method.
 =cut
 
 sub table_info {
+  my $conf = new FS::Conf;
+  my $ip_addr_required = $conf->exists('svc_broadband-allow_null_ip_addr');
   {
     'name' => 'Wireless broadband',
     'name_plural' => 'Wireless broadband services',
@@ -117,7 +119,10 @@ sub table_info {
                          'type'     => 'fcc_477_speed',
                          'def_info' => 'both upload and download speed must be set to FCC 477 information if using that modifier',
                        },
-      'ip_addr'     => 'IP address',
+      'ip_addr'     => {
+                         'label' => 'IP address',
+                         'required' => $ip_addr_required,
+                       },
       'blocknum'    => 
       { 'label' => 'Address block',
                          'type'  => 'select',
index a238a3f..a919c03 100644 (file)
@@ -833,6 +833,7 @@ Example:
 
 my(%opt) = @_;
 
+my $conf = new FS::Conf;
 my $curuser = $FS::CurrentUser::CurrentUser;
 
 #false laziness w/process.html
@@ -845,6 +846,8 @@ my $fields = $opt{'fields'}
 my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields;
 
 push @actualfields, $pkey;
+push @actualfields, 'ip_addr' if $table eq 'svc_broadband';
+push @actualfields, 'usergroup' if ($table eq 'svc_broadband' && $conf->exists('svc_broadband-radius'));
 
 my $js_form_validate = {};
 
index 1175723..7933717 100644 (file)
@@ -105,6 +105,12 @@ Example:
 
 </%doc>
 %if ( $error ) {
+%  ## flatten any array refs so multi selects are sticky on error
+%  for my $param ($cgi->param) {
+%    if (ref($cgi->param($param)) eq "ARRAY") {
+%      $cgi->param($param, (join ",", @{$cgi->param($param)}));
+%    }
+%  }
 %
 %  #my $query = $m->scomp('/elements/create_uri_query');
 %  #$cgi->redirect("$url?$query");
index bcf55fe..374af47 100644 (file)
@@ -109,6 +109,7 @@ my @fields = (
       return () unless $part_svc; #sanity check
       my $col = $part_svc->part_svc_column('ip_addr');
       return () unless $col; #sanity check
+      $col->set('required', 'Y') unless $conf->exists('svc_broadband-allow_null_ip_addr');
       return ('ip_addr_required' => $col->required);
     },
   },