MT#5147 Proper DateTime deflation in Forms

agranig/rest
Gerhard Jungwirth 12 years ago committed by Andreas Granig
parent 273a59ae8c
commit 83a4085255

@ -0,0 +1,37 @@
package NGCP::Panel::Field::DateTime;
use HTML::FormHandler::Moose;
use Sipwise::Base;
extends 'HTML::FormHandler::Field::Text';
has '+deflate_method' => ( default => sub { \&datetime_deflate } );
sub datetime_deflate {
my ( $self, $value ) = @_;
if(blessed($value) && $value->isa('DateTime')) {
return $value->ymd('-') . ' ' . $value->hms(':');;
} else {
return $value;
}
}
1;
=head1 NAME
NGCP::Panel::Field::DateTime
=head1 DESCRIPTION
=head1 AUTHOR
Gerhard Jungwirth
=head1 LICENSE
This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.
=cut
# vim: set tabstop=4 expandtab:

@ -15,7 +15,7 @@ sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'start' => (
type => 'Text',
type => '+NGCP::Panel::Field::DateTime',
element_attr => {
rel => ['tooltip'],
title => ['YYYY-MM-DD HH:mm:ss']
@ -25,7 +25,7 @@ has_field 'start' => (
);
has_field 'end' => (
type => 'Text',
type => '+NGCP::Panel::Field::DateTime',
element_attr => {
rel => ['tooltip'],
title => ['YYYY-MM-DD HH:mm:ss']

Loading…
Cancel
Save