| 1 | package HTML::FormHandler::Field::Multiple; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: multiple select list | ||||||||||||||||||||||||||||
| 3 | 18 | $HTML::FormHandler::Field::Multiple::VERSION = '0.410000'; | |||||||||||||||||||||||||||
| 4 | 18 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 18 | extends 'HTML::FormHandler::Field::Select'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 18 | has '+multiple' => ( default => 1 ); | |||||||||||||||||||||||||||
| 9 | 18 | has '+size' => ( default => 5 ); | |||||||||||||||||||||||||||
| 10 | 29 | ▶ | has '+sort_options_method' => ( default => sub { \&default_sort_options } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub default_sort_options { | ||||||||||||||||||||||||||||
| 13 | 44 | ▶ | my ( $self, $options ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
default_sort_options: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 44 | ▶ | return $options unless scalar @$options && defined $self->value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @$options and defined $self->value
MC/DC50%1/2
scalar @$options and defined $self->value
scalar @$options
defined $self->value
Truth table66%2/3
A and B
A= scalar @$optionsB= defined $self->value
| |||||||||||||||||||||||||||||
| 16 | 40 | my $value = $self->deflate($self->value); | |||||||||||||||||||||||||||
| 17 | 40 | ▶ | return $options unless scalar @$value; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | # This places the currently selected options at the top of the list | ||||||||||||||||||||||||||||
| 19 | # Makes the drop down lists a bit nicer | ||||||||||||||||||||||||||||
| 20 | 6 | my %selected = map { $_ => 1 } @$value; | |||||||||||||||||||||||||||
| 21 | 6 | my @out = grep { $selected{ $_->{value} } } @$options; | |||||||||||||||||||||||||||
| 22 | 6 | push @out, grep { !$selected{ $_->{value} } } @$options; | |||||||||||||||||||||||||||
| 23 | 6 | return \@out; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 18 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 27 | 18 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 18 | 1; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | __END__ | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =pod | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head1 NAME | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | HTML::FormHandler::Field::Multiple - multiple select list | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head1 VERSION | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | version 0.410000 | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | This is a convenience field that inherits from the Select field and | ||||||||||||||||||||||||||||
| 47 | pre-sets some attributes. It sets the 'multiple' flag, | ||||||||||||||||||||||||||||
| 48 | sets the 'size' attribute to 5, and sets the 'sort_options_method' to | ||||||||||||||||||||||||||||
| 49 | move the currently selected options to the top of the options list. | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | FormHandler Contributors - see HTML::FormHandler | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | This software is copyright (c) 2017 by Gerda Shank. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 60 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||||||||||