MT#8621 Check callforward spec against empty desctinations

agranig/webphone
Irka 11 years ago
parent 9e95ee3e8b
commit c7a2dae1fc

@ -1144,7 +1144,7 @@ sub preferences_callforward_advanced :Chained('base') :PathPart('preferences/cal
my @maps = ();
foreach my $map($cf_mapping->all) {
push @maps, {
destination_set => $map->destination_set->id,
destination_set => $map->destination_set ? $map->destination_set->id : undef,
time_set => $map->time_set ? $map->time_set->id : undef,
};
}
@ -1155,6 +1155,7 @@ sub preferences_callforward_advanced :Chained('base') :PathPart('preferences/cal
$cf_form->process(
params => $posted ? $c->request->params : $params,
posted => $posted,
);

@ -103,7 +103,25 @@ has_block 'actions' => (
class => [qw(modal-footer)],
render_list => [qw(cf_actions)],
);
sub validate_active_callforward{
my ( $self, $field ) = @_;
my $value = $field->value || [];
my $result = 1;
if( $#$value < 0 ){
$result = 0;
}else{
foreach my $map (@$value){
if(! defined $map->{destination_set}){
$result = 0;
last;
}
}
}
if(!$result){
$field->add_error($field->label . " is invalid");
}
return $result;
}
1;
# vim: set tabstop=4 expandtab:

Loading…
Cancel
Save