diff --git a/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm b/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm index f055b03297..431b90a2cd 100644 --- a/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm +++ b/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm @@ -235,6 +235,17 @@ has_block 'actions' => ( render_list => [qw/save/], ); +sub validate_timezone { + my ($self, $field) = @_; + my $c = $self->form->ctx; + return unless $c; + + my $value = $field->value; + unless (NGCP::Panel::Utils::DateTime::is_valid_timezone_name($value, 0, $c, 1)) { + $field->add_error($c->loc('Invalid timezone name: '.$value)); + } +} + # override parent here to prevent any password magic sub update_fields { #IMPORTANT! redefined sub update_fields with no super call disable call of the update_field_list and defaults methods @@ -254,7 +265,6 @@ sub update_fields { return; } - 1; # vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Form/Subscriber/SubscriberSubAdminAPI.pm b/lib/NGCP/Panel/Form/Subscriber/SubscriberSubAdminAPI.pm index bc5245e39b..71220bcf23 100644 --- a/lib/NGCP/Panel/Form/Subscriber/SubscriberSubAdminAPI.pm +++ b/lib/NGCP/Panel/Form/Subscriber/SubscriberSubAdminAPI.pm @@ -121,11 +121,11 @@ has_field 'status' => ( ); has_field 'timezone' => ( - type => '+NGCP::Panel::Field::TimezoneSelect', + type => 'Text', label => 'Timezone', element_attr => { rel => ['tooltip'], - title => ['The timezone of the subscriber.'] + title => ['The timezone of the subscriber. See http://search.cpan.org/dist/DateTime-TimeZone/lib/DateTime/TimeZone/Catalog.pm for a full list of valid timezone names.'] }, ); #we need customer_id field in the form to don't delete customer_id from the resource as absent field during form validation @@ -324,6 +324,17 @@ sub validate_webpassword { NGCP::Panel::Utils::Form::validate_password(c => $c, field => $field, utf8 => 0); } +sub validate_timezone { + my ($self, $field) = @_; + my $c = $self->form->ctx; + return unless $c; + + my $value = $field->value; + unless (NGCP::Panel::Utils::DateTime::is_valid_timezone_name($value, 0, $c, 1)) { + $field->add_error($c->loc('Invalid timezone name: '.$value)); + } +} + sub update_fields { #IMPORTANT! redefined sub update_fields with no super call disable call of the update_field_list and defaults methods my ($self) = @_;