| 1 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::Date; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 23 | $HTML::FormFu::Element::Date::VERSION = '2.06'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: 3 select menu multi-field | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 23 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 23 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 23 | extends 'HTML::FormFu::Element::Multi'; | |||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 23 | ▶ | use HTML::FormFu::Util qw( _filter_components _parse_args ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 23 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 23 | ▶ | use DateTime::Format::Builder; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 23 | ▶ | use DateTime::Format::Natural; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 23 | ▶ | use DateTime::Locale; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 23 | ▶ | use Moose::Util qw( apply_all_roles ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 23 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 23 | ▶ | use List::Util 1.45 qw( all none uniq ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 23 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 23 | __PACKAGE__->mk_attrs(qw( day month year )); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 23 | has auto_inflate => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 23 | has default_natural => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 26 | 23 | has default_datetime_args => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 27 | 23 | has printf_day => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 23 | has printf_month => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 23 | has printf_year => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 23 | has _known_fields => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 23 | has strftime => ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | default => '%d-%m-%Y', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | traits => ['Chained'], | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 23 | *default = \&value; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | # build get_Xs methods | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 23 | for my $method ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 44 | deflator filter | ||||||||||||||||||||||||||||||||||||||||||
| 45 | constraint inflator | ||||||||||||||||||||||||||||||||||||||||||
| 46 | validator transformer | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||||||||||||||||
| 49 | my $sub = sub { | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 104 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 104 | my %args = _parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 52 | 104 | my $get_method = "get_${method}s"; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 104 | my $accessor = "_${method}s"; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 104 | my @x = @{ $self->$accessor }; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 104 | push @x, map { @{ $_->$get_method(@_) } } @{ $self->_elements }; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 104 | return _filter_components( \%args, \@x ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 138 | }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 138 | my $name = __PACKAGE__ . "::get_${method}s"; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | ## no critic (ProhibitNoStrict); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 23 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 138 | *{$name} = $sub; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | after BUILD => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 41 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 41 | $self->printf_day('%d'); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 41 | $self->printf_month('%d'); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 41 | $self->printf_year('%d'); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 41 | $self->_known_fields( [qw( day month year )] ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 41 | $self->field_order( [qw( day month year )] ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 41 | $self->day( { prefix => [], } ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 41 | $self->month( { prefix => [], } ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 41 | $self->year( | |||||||||||||||||||||||||||||||||||||||||
| 85 | { prefix => [], | ||||||||||||||||||||||||||||||||||||||||||
| 86 | less => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | plus => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 88 | reverse => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 41 | return; | |||||||||||||||||||||||||||||||||||||||||
| 92 | 23 | }; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub value { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 168 | ▶ | my ( $self, $value ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 168 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 27 | $self->{value} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | # if we're already built - i.e. process() has ben called, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # call default() on our children | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 27 | ▶ | if ( @{ $self->_elements } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | $self->_date_defaults; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 7 | my @order = @{ $self->field_order }; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 7 | for my $i ( 0 .. $#order ) { | |||||||||||||||||||||||||||||||||||||||||
| 109 | 31 | my $field = $order[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 31 | my $printf_method = "printf_$field"; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | my $default | ||||||||||||||||||||||||||||||||||||||||||
| 114 | = $value | ||||||||||||||||||||||||||||||||||||||||||
| 115 | ? sprintf( $self->$printf_method, $self->$field->{default} ) | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 31 | ▶ | : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 31 | $self->_elements->[$i]->default($default); | |||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 27 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 141 | return $self->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | sub _add_elements { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 47 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_elements: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 47 | $self->_elements( [] ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 47 | $self->_date_defaults; | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 47 | for my $order ( @{ $self->field_order } ) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 172 | my $method = "_add_$order"; | |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 172 | $self->$method; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 47 | ▶ | if ( $self->auto_inflate | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->auto_inflate and not @{$self->get_inflators({"type", "DateTime"});}
MC/DC100%2/2
$self->auto_inflate and not @{$self->get_inflators({"type", "DateTime"});}
$self->auto_inflate
not @{$self->get_inflators({"type", "DateTime"});}
Truth table100%3/3
A and not(B)
A= $self->auto_inflateB= not @{$self->get_inflators({"type", "DateTime"});}
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 20 | && !@{ $self->get_inflators( { type => "DateTime" } ) } ) | |||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 10 | _add_inflator($self); | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 47 | return; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | sub _date_defaults { | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 54 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_defaults: called CC=16 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 54 | my $default; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 54 | ▶ | if ( defined( $default = $self->default ) && length $default ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined($default = $self->default) and length $default
MC/DC100%2/2
defined($default = $self->default) and length $default
defined($default = $self->default)
length $default
Truth table100%3/3
A and B
A= defined($default = $self->default)B= length $default
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 38 | ▶ | if ( !$self->form->submitted || $self->render_processed_value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->form->submitted or $self->render_processed_value
MC/DC50%1/2
not $self->form->submitted or $self->render_processed_value
not $self->form->submitted
$self->render_processed_value
Truth table66%2/3
not(A) or B
A= not $self->form->submittedB= $self->render_processed_value
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 32 | for my $deflator ( @{ $self->_deflators } ) { | |||||||||||||||||||||||||||||||||||||||||
| 159 | 1 | $default = $deflator->process($default); | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 38 | my $is_blessed = blessed($default); | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 38 | ▶ | if ( !$is_blessed || ( $is_blessed && !$default->isa('DateTime') ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not $is_blessed or $is_blessed and not $default->isa("DateTime")
$is_blessed and not $default->isa("DateTime")
MC/DC33%1/3
not $is_blessed or $is_blessed and not $default->isa("DateTime")
not $is_blessed
$is_blessed
not $default->isa("DateTime")
Truth table50%2/4
not(A) or B and not(C)
A= not $is_blessedB= $is_blessedC= not $default->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 19 | my $builder = DateTime::Format::Builder->new; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 19 | $builder->parser( { strptime => $self->strftime } ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 19 | $default = $builder->parse_datetime($default); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif ( defined( $default = $self->default_natural ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | my $parser; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 3 | ▶ | if ( defined( my $datetime_args = $self->default_datetime_args ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | if ( exists $datetime_args->{set_time_zone} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | my $tz = $datetime_args->{set_time_zone}; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | $parser = DateTime::Format::Natural->new( time_zone => $tz ); | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | $parser = DateTime::Format::Natural->new; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | $parser = DateTime::Format::Natural->new; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | $default = $parser->parse_datetime($default); | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 13 | $default = undef; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 54 | ▶ | if ( defined $default ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 41 | ▶ | if ( defined( my $datetime_args = $self->default_datetime_args ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | for my $key ( keys %$datetime_args ) { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | $default->$key( $datetime_args->{$key} ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 41 | for my $field ( @{ $self->field_order } ) { | |||||||||||||||||||||||||||||||||||||||||
| 202 | 153 | $self->$field->{default} = $default->$field; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 54 | return; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | sub _add_day { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 43 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_day: called CC=5 SCAR=16.9
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 43 | my $day = $self->day; | |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 43 | my $day_name = $self->_build_name('day'); | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | my @day_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 217 | = ref $day->{prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 31 | ? @{ $day->{prefix} } | |||||||||||||||||||||||||||||||||||||||||
| 219 | 43 | ▶ | : $day->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 43 | ▶ | if ( exists $day->{prefix_loc} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | @day_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 223 | = ref $day->{prefix_loc} | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ? map { $self->form->localize($_) } @{ $day->{prefix_loc} } | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | : $self->form->localize( $day->{prefix_loc} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 43 | @day_prefix = map { [ '', $_ ] } @day_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | my $element = $self->element( | ||||||||||||||||||||||||||||||||||||||||||
| 231 | { type => 'Select', | ||||||||||||||||||||||||||||||||||||||||||
| 232 | name => $day_name, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 1333 | ▶ | options => [ @day_prefix, map { [ $_, $_ ] } 1 .. 31 ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | attributes => $day->{attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 43 | defined $day->{default} ? ( default => $day->{default} ) : (), | |||||||||||||||||||||||||||||||||||||||||
| 237 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 43 | apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 43 | return; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | sub _add_month { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 47 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_month: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 47 | my $month = $self->month; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 47 | my $month_name = $self->_build_name('month'); | |||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 47 | my @months = _build_month_list($self); | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | my @month_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 254 | = ref $month->{prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 33 | ? @{ $month->{prefix} } | |||||||||||||||||||||||||||||||||||||||||
| 256 | 47 | ▶ | : $month->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 47 | ▶ | if ( exists $month->{prefix_loc} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | @month_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 260 | = ref $month->{prefix_loc} | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ? map { $self->form->localize($_) } @{ $month->{prefix_loc} } | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | : $self->form->localize( $month->{prefix_loc} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 47 | @month_prefix = map { [ '', $_ ] } @month_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 47 | my $options = [ @month_prefix, map { [ $_ + 1, $months[$_] ] } 0 .. 11 ]; | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | my $element = $self->element( | ||||||||||||||||||||||||||||||||||||||||||
| 270 | { type => 'Select', | ||||||||||||||||||||||||||||||||||||||||||
| 271 | name => $month_name, | ||||||||||||||||||||||||||||||||||||||||||
| 272 | options => $options, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | attributes => $month->{attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 47 | ▶ | defined $month->{default} ? ( default => $month->{default} ) : (), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 47 | apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 47 | return; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | sub _add_year { | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 47 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_year: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 47 | my $year = $self->year; | |||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 47 | my $year_name = $self->_build_name('year'); | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | my $year_ref | ||||||||||||||||||||||||||||||||||||||||||
| 291 | = defined $year->{reference} | ||||||||||||||||||||||||||||||||||||||||||
| 292 | ? $year->{reference} | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 47 | ▶ | : ( localtime(time) )[5] + 1900; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | my @years | ||||||||||||||||||||||||||||||||||||||||||
| 296 | = defined $year->{list} | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 36 | ? @{ $year->{list} } | |||||||||||||||||||||||||||||||||||||||||
| 298 | 47 | ▶ | : ( $year_ref - $year->{less} ) .. ( $year_ref + $year->{plus} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 47 | ▶ | if ( $year->{reverse} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | @years = reverse(@years); | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | my @year_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 305 | = ref $year->{prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 33 | ? @{ $year->{prefix} } | |||||||||||||||||||||||||||||||||||||||||
| 307 | 47 | ▶ | : $year->{prefix}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 47 | ▶ | if ( exists $year->{prefix_loc} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | @year_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 311 | = ref $year->{prefix_loc} | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ? map { $self->form->localize($_) } @{ $year->{prefix_loc} } | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | : $self->form->localize( $year->{prefix_loc} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 47 | @year_prefix = map { [ '', $_ ] } @year_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | my $element = $self->element( | ||||||||||||||||||||||||||||||||||||||||||
| 319 | { type => 'Select', | ||||||||||||||||||||||||||||||||||||||||||
| 320 | name => $year_name, | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 403 | ▶ | options => [ @year_prefix, map { [ $_, $_ ] } @years ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | attributes => $year->{attributes}, | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 47 | defined $year->{default} ? ( default => $year->{default} ) : (), | |||||||||||||||||||||||||||||||||||||||||
| 325 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 47 | apply_all_roles( $element, 'HTML::FormFu::Role::Element::MultiElement' ); | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 47 | return; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | sub _build_month_list { | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 47 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_month_list: called CC=6 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 47 | my $month = $self->month; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 47 | my @months; | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 47 | ▶ | if ( defined $month->{names} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | @months = @{ $month->{names} }; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 47 | my $languages = $self->form->languages; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 47 | ▶ | if ( ref $languages ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $languages = [$languages]; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 47 | for my $lang (@$languages) { | |||||||||||||||||||||||||||||||||||||||||
| 348 | 47 | my $loc; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 47 | eval { $loc = DateTime::Locale->load($lang) }; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 47 | ▶ | if ( !$@ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | @months | ||||||||||||||||||||||||||||||||||||||||||
| 353 | = $month->{short_names} | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 14 | ? @{ $loc->month_format_abbreviated } | |||||||||||||||||||||||||||||||||||||||||
| 355 | 47 | ▶ | : @{ $loc->month_format_wide }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 47 | @months = map {ucfirst} @months; | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 47 | last; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 47 | return @months; | |||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | sub _build_number_list { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 19 | ▶ | my ( $self, $start, $end, $interval ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_number_list: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 19 | ▶ | $interval ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$interval ||= 1
MC/DC100%1/1
$interval ||= 1
$interval
Truth table100%2/2
A
A= $interval
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 19 | my @list; | |||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 19 | ▶ | for ( my $i = $start; $i <= $end; $i += $interval ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 1034 | push @list, $i; | |||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 19 | return @list; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | sub _build_name { | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 172 | ▶ | my ( $self, $type ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_name: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | my $name | ||||||||||||||||||||||||||||||||||||||||||
| 385 | = defined $self->$type->{name} | ||||||||||||||||||||||||||||||||||||||||||
| 386 | ? $self->$type->{name} | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 172 | ▶ | : sprintf "%s_%s", $self->name, $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 172 | return $name; | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | sub _add_inflator { | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 10 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_inflator: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 10 | $self->inflator( | |||||||||||||||||||||||||||||||||||||||||
| 396 | { type => "DateTime", | ||||||||||||||||||||||||||||||||||||||||||
| 397 | parser => { strptime => $self->strftime, }, | ||||||||||||||||||||||||||||||||||||||||||
| 398 | strptime => $self->strftime, | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | sub field_order { | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 173 | ▶ | my ( $self, @order ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
field_order: called CC=7 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 173 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 60 | ▶ | if ( @order == 1 && ref( $order[0] ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@order == 1 and ref $order[0] eq "ARRAY"
MC/DC0%0/2
@order == 1 and ref $order[0] eq "ARRAY"
@order == 1
ref $order[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @order == 1B= ref $order[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | 60 | @order = @{ $order[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 60 | for my $field (@order) { | |||||||||||||||||||||||||||||||||||||||||
| 413 | croak "unknown field type: '$field'" | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 206 | ▶ | if none { $field eq $_ } @{ $self->_known_fields }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 59 | ▶ | croak 'repeated field type' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | if scalar( uniq @order ) != scalar(@order); | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 58 | $self->{field_order} = \@order; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 58 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 113 | return $self->{field_order}; | |||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | sub process { | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 47 | ▶ | my ( $self, @args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 47 | $self->_add_elements; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 47 | return $self->SUPER::process(@args); | |||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | sub process_input { | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 18 | ▶ | my ( $self, $input ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process_input: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 18 | my %value; | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 18 | my @order = @{ $self->field_order }; | |||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 18 | for my $i ( 0 .. $#order ) { | |||||||||||||||||||||||||||||||||||||||||
| 445 | 63 | my $field = $order[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 63 | my $name = $self->_elements->[$i]->nested_name; | |||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | 63 | $value{$field} = $self->get_nested_hash_value( $input, $name ); | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 18 | ▶ | if ( ( all {defined} values %value ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
Condition100%3/3
&all(sub { and &all(sub {
MC/DC100%2/2
&all(sub {
defined $_;
}
, values %value) and &all(sub {
length $_;
}
, values %value)
&all(sub {
defined $_;
}
, values %value)
&all(sub {
length $_;
}
, values %value)
Truth table100%3/3
A and B
A= &all(sub {
defined $_;
}
, values %value)B= &all(sub {
length $_;
}
, values %value)
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 50 | ▶ | && all {length} values %value ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 14 | my $dt; | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 14 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 458 | 14 | $dt = DateTime->new( map { $_, $value{$_} } keys %value ); | |||||||||||||||||||||||||||||||||||||||||
| 459 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 14 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | 14 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | $value = $self->strftime; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 11 | $value = $dt->strftime( $self->strftime ); | |||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 14 | $self->set_nested_hash_value( $input, $self->nested_name, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 18 | return $self->SUPER::process_input($input); | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | sub render_data { | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 47 | ▶ | return shift->render_data_non_recursive(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | sub render_data_non_recursive { | ||||||||||||||||||||||||||||||||||||||||||
| 481 | 47 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_data_non_recursive: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | my $render = $self->SUPER::render_data_non_recursive( | ||||||||||||||||||||||||||||||||||||||||||
| 484 | 47 | ▶ | { elements => [ map { $_->render_data } @{ $self->_elements } ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | $args ? %$args : (), | ||||||||||||||||||||||||||||||||||||||||||
| 486 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 47 | return $render; | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 23 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | 23 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | HTML::FormFu::Element::Date - 3 select menu multi-field | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | version 2.06 | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | --- | ||||||||||||||||||||||||||||||||||||||||||
| 512 | elements: | ||||||||||||||||||||||||||||||||||||||||||
| 513 | - type: Date | ||||||||||||||||||||||||||||||||||||||||||
| 514 | name: birthdate | ||||||||||||||||||||||||||||||||||||||||||
| 515 | label: 'Birthdate:' | ||||||||||||||||||||||||||||||||||||||||||
| 516 | day: | ||||||||||||||||||||||||||||||||||||||||||
| 517 | prefix: "- Day -" | ||||||||||||||||||||||||||||||||||||||||||
| 518 | month: | ||||||||||||||||||||||||||||||||||||||||||
| 519 | prefix: "- Month -" | ||||||||||||||||||||||||||||||||||||||||||
| 520 | year: | ||||||||||||||||||||||||||||||||||||||||||
| 521 | prefix: "- Year -" | ||||||||||||||||||||||||||||||||||||||||||
| 522 | less: 70 | ||||||||||||||||||||||||||||||||||||||||||
| 523 | plus: 0 | ||||||||||||||||||||||||||||||||||||||||||
| 524 | auto_inflate: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | Creates a L<multi|HTML::FormFu::Element::Multi> element containing 3 select | ||||||||||||||||||||||||||||||||||||||||||
| 529 | menus for the day, month and year. | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | A date element named C<foo> would result in 3 select menus with the names | ||||||||||||||||||||||||||||||||||||||||||
| 532 | C<foo_day>, C<foo_month> and C<foo_year>. The names can instead be | ||||||||||||||||||||||||||||||||||||||||||
| 533 | overridden by the C<name> value in L</day>, L</month> and L</year>. | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | This element automatically merges the input parameters from the select | ||||||||||||||||||||||||||||||||||||||||||
| 536 | menu into a single date parameter (and doesn't delete the individual menu's | ||||||||||||||||||||||||||||||||||||||||||
| 537 | parameters). | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | =head2 default | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | Arguments: DateTime object | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | Arguments: $date_string | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | Accepts either a L<DateTime> object, or a string containing a date, matching | ||||||||||||||||||||||||||||||||||||||||||
| 548 | the L</strftime> format. Overwrites any default value set in L</day>, | ||||||||||||||||||||||||||||||||||||||||||
| 549 | L</month> or L</year>. | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | =head2 default_natural | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | Arguments: $date_string | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | - type: Date | ||||||||||||||||||||||||||||||||||||||||||
| 556 | default_natural: 'today' | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | Accepts a date/time string suitable for passing to | ||||||||||||||||||||||||||||||||||||||||||
| 559 | L<DateTime::Format::Natural/parse_datetime>. | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | =head2 default_datetime_args | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | - type: Date | ||||||||||||||||||||||||||||||||||||||||||
| 564 | default_natural: 'today' | ||||||||||||||||||||||||||||||||||||||||||
| 565 | default_datetime_args: | ||||||||||||||||||||||||||||||||||||||||||
| 566 | set_time_zone: 'Europe/London' | ||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | Accepts a hashref of method-names / values that will be called on the | ||||||||||||||||||||||||||||||||||||||||||
| 569 | L</default> L<DateTime|DateTime> object, before the select fields' values | ||||||||||||||||||||||||||||||||||||||||||
| 570 | are set from it. | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | =head2 strftime | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | Default Value: "%d-%m-%Y" | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | The format of the date as returned by L<HTML::FormFu/params>, if | ||||||||||||||||||||||||||||||||||||||||||
| 577 | L</auto_inflate> is not set. | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | If L</auto_inflate> is used, this is still the format that the parameter | ||||||||||||||||||||||||||||||||||||||||||
| 580 | will be in prior to the DateTime inflator being run; which is | ||||||||||||||||||||||||||||||||||||||||||
| 581 | what any L<Filters|HTML::FormFu::Filter> and | ||||||||||||||||||||||||||||||||||||||||||
| 582 | L<Constraints|HTML::FormFu::Constraint> will receive. | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | =head2 day | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | Arguments: \%setting | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | Set values effecting the C<day> select menu. Known keys are: | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | =head3 name | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | Override the auto-generated name of the select menu. | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | =head3 default | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | Set the default value of the select menu | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | =head3 prefix | ||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||
| 600 | Arguments: $value | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | Arguments: \@values | ||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||
| 604 | A string or arrayref of strings to be inserted into the start of the select | ||||||||||||||||||||||||||||||||||||||||||
| 605 | menu. | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | Each value is only used as the label for a select item - the value for each | ||||||||||||||||||||||||||||||||||||||||||
| 608 | of these items is always the empty string C<''>. | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | =head3 prefix_loc | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | Arguments: $localization_key | ||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | Arguments: \@localization_keys | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | A localized string or arrayref of localized strings to be inserted into the | ||||||||||||||||||||||||||||||||||||||||||
| 617 | start of the select menu. | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | Each value is localized and then only used as the label for a select item | ||||||||||||||||||||||||||||||||||||||||||
| 620 | - the value for each of these items is always the empty string C<''>. | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | Use C<prefix_loc> insted of C<prefix>. | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | =head2 month | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | Arguments: \%setting | ||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | Set values effecting the C<month> select menu. Known keys are: | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | =head3 name | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | Override the auto-generated name of the select menu. | ||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | =head3 default | ||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||
| 636 | Set the default value of the select menu | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | =head3 prefix | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | Arguments: $value | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | Arguments: \@values | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | A string or arrayref of strings to be inserted into the start of the select | ||||||||||||||||||||||||||||||||||||||||||
| 645 | menu. | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | Each value is only used as the label for a select item - the value for each | ||||||||||||||||||||||||||||||||||||||||||
| 648 | of these items is always the empty string C<''>. | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | =head3 prefix_loc | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | Arguments: $localization_key | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | Arguments: \@localization_keys | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | A localized string or arrayref of localized strings to be inserted into the | ||||||||||||||||||||||||||||||||||||||||||
| 657 | start of the select menu. | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | Each value is localized and then only used as the label for a select item | ||||||||||||||||||||||||||||||||||||||||||
| 660 | - the value for each of these items is always the empty string C<''>. | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | Use C<prefix_loc> insted of C<prefix>. | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | =head3 names | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | Arguments: \@months | ||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||
| 668 | A list of month names used for the month menu. | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | If not set, the list of month names is obtained from L<DateTime::Locale> | ||||||||||||||||||||||||||||||||||||||||||
| 671 | using the locale set in L<HTML::FormFu/languages>. | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | =head3 short_names | ||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||
| 675 | Argument: bool | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | If true (and C<months> is not set) the list of abbreviated month names is | ||||||||||||||||||||||||||||||||||||||||||
| 678 | obtained from L<DateTime::Locale> using the locale set in | ||||||||||||||||||||||||||||||||||||||||||
| 679 | L<HTML::FormFu/languages>. | ||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | =head2 year | ||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||
| 683 | Arguments: \%setting | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | Set values effecting the C<year> select menu. Known keys are: | ||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | =head3 name | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | Override the auto-generated name of the select menu. | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | =head3 default | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | Set the default value of the select menu | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | =head3 prefix | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | Arguments: $value | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | Arguments: \@values | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | A string or arrayref of strings to be inserted into the start of the select | ||||||||||||||||||||||||||||||||||||||||||
| 702 | menu. | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | Each value is only used as the label for a select item - the value for each | ||||||||||||||||||||||||||||||||||||||||||
| 705 | of these items is always the empty string C<''>. | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | =head3 prefix_loc | ||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | Arguments: $localization_key | ||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | Arguments: \@localization_keys | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | A localized string or arrayref of localized strings to be inserted into the | ||||||||||||||||||||||||||||||||||||||||||
| 714 | start of the select menu. | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | Each value is localized and then only used as the label for a select item | ||||||||||||||||||||||||||||||||||||||||||
| 717 | - the value for each of these items is always the empty string C<''>. | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | Use C<prefix_loc> insted of C<prefix>. | ||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | =head3 list | ||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||
| 723 | Arguments: \@years | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | A list of years used for the year menu. | ||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | If this is set, C<reference>, C<less> and C<plus> are ignored. | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | =head3 reference | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | Arguments: $year | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | Default Value: the current year, calculated from L<time()|perlfunc/time()> | ||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||
| 735 | If C<list> is not set, the list is created from the range of | ||||||||||||||||||||||||||||||||||||||||||
| 736 | C<reference - year_less> to C<reference + year_plus>. | ||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | =head3 less | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | Arguments: $count | ||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | Default Value: 0 | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | =head3 plus | ||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||
| 746 | Arguments: $count | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | Default Value: 10 | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | =head3 reverse | ||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | Arguments: bool | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | Default Value: 0 | ||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||
| 756 | If true, the list of years is listed in reverse (decreasing) order. | ||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||
| 758 | =head2 field_order | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | Arguments: \@fields | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | Default Value: ['day', 'month', 'year'] | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | Specify the order of the date fields in the rendered HTML. | ||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||
| 766 | Not all 3 fields are required. No single field can be used more than once. | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | =head2 auto_inflate | ||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||
| 770 | If true, a L<DateTime Inflator|HTML::FormFu::Inflator::DateTime> will | ||||||||||||||||||||||||||||||||||||||||||
| 771 | automatically be added to the element, and it will be given a formatter so | ||||||||||||||||||||||||||||||||||||||||||
| 772 | that stringification will result in the format specified in L</strftime>. | ||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | If you require the DateTime Inflator to have a different stringification | ||||||||||||||||||||||||||||||||||||||||||
| 775 | format to the format used internally by your Filters and Constraints, then | ||||||||||||||||||||||||||||||||||||||||||
| 776 | you must explicitly add your own DateTime Inflator, rather than using | ||||||||||||||||||||||||||||||||||||||||||
| 777 | L</auto_inflate>. | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | =head1 CAVEATS | ||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | Although this element inherits from L<HTML::FormFu::Element::Block>, its | ||||||||||||||||||||||||||||||||||||||||||
| 782 | behaviour for the methods | ||||||||||||||||||||||||||||||||||||||||||
| 783 | L<filterE<sol>filters|HTML::FormFu/filters>, | ||||||||||||||||||||||||||||||||||||||||||
| 784 | L<constraintE<sol>constraints|HTML::FormFu/constraints>, | ||||||||||||||||||||||||||||||||||||||||||
| 785 | L<inflatorE<sol>inflators|HTML::FormFu/inflators>, | ||||||||||||||||||||||||||||||||||||||||||
| 786 | L<validatorE<sol>validators|HTML::FormFu/validators> and | ||||||||||||||||||||||||||||||||||||||||||
| 787 | L<transformerE<sol>transformers|HTML::FormFu/transformers> is more like that of | ||||||||||||||||||||||||||||||||||||||||||
| 788 | a L<field element|HTML::FormFu::Role::Element::Field>, meaning all processors are | ||||||||||||||||||||||||||||||||||||||||||
| 789 | added directly to the date element, not to its select-menu child elements. | ||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | This element's L<get_elements|HTML::FormFu/get_elements> and | ||||||||||||||||||||||||||||||||||||||||||
| 792 | L<get_all_elements|HTML::FormFu/get_all_elements> are inherited from | ||||||||||||||||||||||||||||||||||||||||||
| 793 | L<HTML::FormFu::Element::Block>, and so have the same behaviour. However, it | ||||||||||||||||||||||||||||||||||||||||||
| 794 | overrides the C<get_fields|HTML::FormFu/get_fields> method, such that it | ||||||||||||||||||||||||||||||||||||||||||
| 795 | returns both itself and its child elements. | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | Is a sub-class of, and inherits methods from | ||||||||||||||||||||||||||||||||||||||||||
| 800 | L<HTML::FormFu::Role::Element::Field>, | ||||||||||||||||||||||||||||||||||||||||||
| 801 | L<HTML::FormFu::Element::Multi>, | ||||||||||||||||||||||||||||||||||||||||||
| 802 | L<HTML::FormFu::Element::Block>, | ||||||||||||||||||||||||||||||||||||||||||
| 803 | L<HTML::FormFu::Element> | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | L<HTML::FormFu> | ||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | Carl Franks, C<cfranks@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | This library is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 814 | the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 825 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | =cut | ||||||||||||||||||||||||||||||||||||||||||