diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index abb858c32..114a2e19f 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -253,12 +253,9 @@ sub bodies : Path('bodies') : Args(0) { my $params = $c->forward('body_params'); my $body = $c->model('DB::Body')->create( $params ); - my $area_ids = $c->get_param('area_ids'); - if ($area_ids) { - $area_ids = [ $area_ids ] unless ref $area_ids; - foreach (@$area_ids) { - $c->model('DB::BodyArea')->create( { body => $body, area_id => $_ } ); - } + my @area_ids = $c->get_param_list('area_ids'); + foreach (@area_ids) { + $c->model('DB::BodyArea')->create( { body => $body, area_id => $_ } ); } $c->stash->{updated} = _('New body added'); @@ -413,13 +410,10 @@ sub update_contacts : Private { $c->stash->{body}->update( $params ); my @current = $c->stash->{body}->body_areas->all; my %current = map { $_->area_id => 1 } @current; - my $area_ids = $c->get_param('area_ids'); - if ($area_ids) { - $area_ids = [ $area_ids ] unless ref $area_ids; - foreach (@$area_ids) { - $c->model('DB::BodyArea')->find_or_create( { body => $c->stash->{body}, area_id => $_ } ); - delete $current{$_}; - } + my @area_ids = $c->get_param_list('area_ids'); + foreach (@area_ids) { + $c->model('DB::BodyArea')->find_or_create( { body => $c->stash->{body}, area_id => $_ } ); + delete $current{$_}; } # Remove any others $c->stash->{body}->body_areas->search( { area_id => [ keys %current ] } )->delete; |