Form::Sensible::Field::DateTime - A DateTime field type.
use Form::Sensible::Field::DateTime; my $object = Form::Sensible::Field::DateTime->new( span => datetime_span_object, recurrence => $recurrence_sub, ); $object->do_stuff(); my $object2 = Form::Sensible::Field::DateTime->new( span => datetime_span_object, recurrence => 'hourly', ); $object2->do_stuff();
The datetime field type is one of the more advanced field types in Form::Sensible. It uses DateTime::Format::Natural to format user input into a valid DateTime object, and uses DateTime::Set to allow date range numbers. It can be set to have a lower and upper bound, allowing validation to ensure that the value selected is within a range.
Finally, it can be rendered in a number of ways including select boxes, drop downs or even ranged-sliders if your renderer supports it. It can have a 'recurrence', which provides a constraint to what values are valid between the datetime span, otherwise it just returns the DateTime value set for the field.
recurrence
A subroutine that is used when this field is used as a Select field. See the from_recurrence method in DateTime::Set for more information on how you might structure the subroutine. Only useful when span is defined. As a convenience, if you pass the following strings, they will DWYM:
from_recurrence
span
A DateTime::Span object that is used to represent the valid date range for this field.
validate
Validates the field against the numeric constraints set for the field.
get_additional_configuration
Returns a hashref consisting of the attributes for this field and their values.
The following two methods allow DateTime fields to be treated like Select Fields for rendering purposes.
get_options()
An array ref containing the allowed options. Each option is represented as a hash containing a name element and a value element for the given option.
name
value
set_selection()
Sets whatever is the current $self->value option as the selected option selected. This is used when a DateTime field is used as a Select field and overrides Select's set_selection method.
$self->value
DateTime
Select
set_selection
accepts_multiple
On a Select field, this defines whether the field can have multiple values. For a DateTime field, only one value is allowed, so this always returns false.
David Romano - <unobe@cpan.org>
Ionzero LLC. http://ionzero.com/
Form::Sensible
Copyright (c) 2012 by Ionzero LLC
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Form::Sensible, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Form::Sensible
CPAN shell
perl -MCPAN -e shell install Form::Sensible
For more information on module installation, please visit the detailed CPAN module installation guide.