RT# 83205 - fixed error with fields being sticky on error
[freeside.git] / httemplate / edit / tower.html
index 14f2dfa..f2faa5a 100644 (file)
@@ -13,8 +13,8 @@
                         'altitude',
                         'height',
                         'veg_height',
-                        'up_rate',
-                        'down_rate',
+                        'up_rate_limit',
+                        'down_rate_limit',
 #                        { field             => 'sectornum',
 #                          type              => 'tower_sector',
 #                          o2m_table         => 'tower_sector',
@@ -37,8 +37,8 @@
                         'height'          => 'Tower height (feet)',
                         'veg_height'      => 'Vegetation height (feet)',
                         'color'           => 'Color',
-                        'up_rate'         => 'Up Rate (Kbps)',
-                        'down_rate'       => 'Down Rate (Kbps)',
+                        'up_rate_limit'   => 'Up Rate Limit(Kbps)',
+                        'down_rate_limit' => 'Down Rate Limit(Kbps)',
                       },
 &>
 <%init>
@@ -47,19 +47,23 @@ my $m2_error_callback = sub { # reconstruct the list
   my ($cgi, $object) = @_;
 
   my @fields = qw(
-    sectorname ip_addr height freq_mhz direction width tilt v_width db_high db_low sector_range up_rate down_rate
+    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 {