File Coverage

blib/lib/Data/MuForm/Field/Checkbox.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 2 100.0
condition 3 3 100.0
subroutine 4 4 100.0
pod 1 3 33.3
total 21 23 91.3


line stmt bran cond sub pod time code
1             package Data::MuForm::Field::Checkbox;
2             # ABSTRACT: Checkbox field
3 13     13   7554 use Moo;
  13         19  
  13         74  
4             extends 'Data::MuForm::Field';
5              
6              
7             has 'size' => ( is => 'rw', default => 0 );
8              
9             has 'checkbox_value' => ( is => 'rw', default => 1 );
10             has '+input_without_param' => ( default => 0 );
11             #has 'option_label' => ( is => 'rw' );
12             #has 'option_wrapper' => ( is => 'rw' );
13              
14 9     9 0 498 sub build_input_type { 'checkbox' }
15              
16             sub base_render_args {
17 11     11 0 1169 my $self = shift;
18 11         47 my $args = $self->next::method(@_);
19 11         33 $args->{checkbox_value} = $self->checkbox_value;
20 11         16 $args->{layout_type} = 'checkbox';
21 11         34 return $args;
22             }
23              
24              
25             sub validate {
26 30     30 1 33 my $self = shift;
27              
28 30 100 100     123 $self->add_error($self->get_message('required'), field_label => $self->loc_label) if( $self->required && !$self->value );
29             }
30              
31             1;
32              
33             __END__
34              
35             =pod
36              
37             =encoding UTF-8
38              
39             =head1 NAME
40              
41             Data::MuForm::Field::Checkbox - Checkbox field
42              
43             =head1 VERSION
44              
45             version 0.03
46              
47             =head1 DESCRIPTION
48              
49             Render args:
50             option_label
51             option_wrapper
52              
53             =head1 NAME
54              
55             Data::MuForm::Field::Checkbox
56              
57             =head1 AUTHOR
58              
59             Gerda Shank
60              
61             =head1 COPYRIGHT AND LICENSE
62              
63             This software is copyright (c) 2017 by Gerda Shank.
64              
65             This is free software; you can redistribute it and/or modify it under
66             the same terms as the Perl 5 programming language system itself.
67              
68             =cut