« Jifty/Plugin/Authentication/Password/Action/ConfirmEmail.pm
↑ Summary
Jifty/Plugin/SetupWizard.pm »
| 1 | use warnings; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | package Jifty::Web::Form::Field::DateTime; | ||
| 5 | |||
| 6 | use base qw/Jifty::Web::Form::Field/; | ||
| 7 | |||
| 8 | =head1 NAME | ||
| 9 | |||
| 10 | Jifty::Web::Form::Field::DateTime - Add date pickers to your forms | ||
| 11 | |||
| 12 | =head1 METHODS | ||
| 13 | |||
| 14 | =head2 classes | ||
| 15 | |||
| 16 | Output date fields with the class 'date' | ||
| 17 | |||
| 18 | =cut | ||
| 19 | |||
| 20 | sub classes { | ||
| 21 | my $self = shift; | ||
| 22 | return join(' ', 'datetime', ($self->SUPER::classes)); | ||
| 23 | } | ||
| 24 | |||
| 25 | =head2 canonicalize_value | ||
| 26 | |||
| 27 | If the value is a DateTime, return nothing if the epoch is 0 | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | sub canonicalize_value { | ||
| 32 | my $self = shift; | ||
| 33 | my $value = $self->current_value; | ||
| 34 | |||
| 35 | if (UNIVERSAL::isa($value, 'DateTime')) { | ||
| 36 | return unless $value->epoch; | ||
| 37 | } | ||
| 38 | |||
| 39 | return $value; | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; |