RT# 83205 - fixed error with fields being sticky on error
authorChristopher Burger <burgerc@freeside.biz>
Wed, 1 May 2019 16:06:18 +0000 (12:06 -0400)
committerChristopher Burger <burgerc@freeside.biz>
Wed, 1 May 2019 16:06:18 +0000 (12:06 -0400)
httemplate/edit/tower.html

index dfebc00..f2faa5a 100644 (file)
@@ -50,16 +50,20 @@ my $m2_error_callback = sub { # reconstruct the list
     sectorname ip_addr height freq_mhz direction width tilt v_width db_high db_low sector_range up_rate_limit down_rate_limit
   );
 
     sectorname ip_addr height freq_mhz direction width tilt v_width db_high db_low sector_range up_rate_limit down_rate_limit
   );
 
-  map {
-    my $k = $_;
-    new FS::tower_sector {
-      'towernum'  => $object->towernum,
-      'sectornum' => scalar( $cgi->param($k) ),
-      map { $_ => scalar( $cgi->param($k.'_'.$_) ) } @fields,
-    };
-  } grep length($cgi->param($_.'_sectorname')),
-      grep /^sectornum\d+$/,
-        ($cgi->param);
+  my @sectors;
+  foreach my $k ($cgi->param) {
+    if ($k =~ /^sectornum\d+$/) {
+      my $sectornum = $cgi->param($k);
+      my $sector = FS::tower_sector->new({
+        'sectornum' => $sectornum,
+        'towernum'  => $object->towernum,
+        map { $_ => scalar($cgi->param($k.'_'.$_)) } @fields,
+      });
+      push @sectors, $sector if length($sector->sectorname) && $sector->sectorname ne '_default';
+    }
+  }
+
+  return @sectors;
 };
 
 my $default_ip_addr_callback = sub {
 };
 
 my $default_ip_addr_callback = sub {