
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.

recurrenceA 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:
spanA DateTime::Span object that is used to represent the valid date range for this field.

validateValidates the field against the numeric constraints set for the field.
get_additional_configurationReturns 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.
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.
accepts_multipleOn 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/


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.