File Coverage

blib/lib/Moonshine/Bootstrap/Component/NavbarForm.pm
Criterion Covered Total %
statement 21 22 95.4
branch 3 4 75.0
condition 1 2 50.0
subroutine 4 4 100.0
pod n/a
total 29 32 90.6


line stmt bran cond sub pod time code
1             package Moonshine::Bootstrap::Component::NavbarForm;
2              
3 7     7   212494 use Moonshine::Magic;
  7         91891  
  7         51  
4 7     7   3481 use Params::Validate qw/ARRAYREF/;
  7         14  
  7         520  
5              
6 7     7   662 use Switch::Back;
  7         1566713  
  7         78  
7              
8             lazy_components qw/form/;
9              
10             extends (
11             'Moonshine::Bootstrap::Component',
12             'Moonshine::Bootstrap::Component::SubmitButton',
13             'Moonshine::Bootstrap::Component::FormGroup',
14             );
15              
16             has(
17             navbar_form_spec => sub {
18             {
19             alignment_base => { default => 'navbar-' },
20             class_base => { default => 'navbar-form' },
21             role => 0,
22             fields => {
23             type => ARRAYREF,
24             build => 1,
25             }
26             };
27             }
28             );
29              
30             sub navbar_form {
31 11     11   24758 my ($self) = shift;
32              
33 11   50     157 my ( $base_args, $build_args ) = $self->validate_build(
34             {
35             params => $_[0] // {},
36             spec => $self->navbar_form_spec,
37             }
38             );
39              
40 11         271 my $form = $self->form($base_args);
41              
42 11         30043 for my $field ( @{ $build_args->{fields} } ) {
  11         63  
  19         271  
43 19 100       51 given ( delete $field->{field_type} ) {
  19 50       1032  
  19         119  
44 0         0 when ('submit_button') {
45 11         1817 $form->add_child( $self->submit_button( $field ) );
46             }
47             when ('form_group') {
48 8         2336 $form->add_child( $self->form_group($field) );
49             }
50             }
51             }
52              
53 11         28191 return $form
54             }
55              
56             1;
57              
58             __END__