& elements/edit.html,
name_singular => 'tower',
table => 'tower',
viewall_dir => 'browse',
fields => [ 'towername',
{ field=>'disabled', type=>'checkbox', value=>'Y', },
{ field=>'color', type=>'pickcolor' },
{ field => 'default_ip_addr',
curr_value_callback => $default_ip_addr_callback },
'latitude',
'longitude',
'altitude',
'height',
'veg_height',
{ field => 'sectornum',
type => 'tower_sector',
o2m_table => 'tower_sector',
m2_label => 'Sector',
m2_error_callback => $m2_error_callback,
},
],
labels => { 'towernum' => 'Tower',
'towername' => 'Name',
'sectornum' => 'Sector',
'disabled' => 'Disabled',
'default_ip_addr' => 'Tower IP address',
'latitude' => 'Latitude',
'longitude' => 'Longitude',
'altitude' => 'Altitude (feet)',
'height' => 'Height (feet)',
'veg_height' => 'Vegetation height (feet)',
'color' => 'Color',
},
&>
<%init>
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 margin sector_range
);
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 $default_ip_addr_callback = sub {
my ($cgi, $object) = @_;
my $sector = $object ? $object->default_sector : '';
$sector ? $sector->ip_addr : '';
};
%init>