File Coverage

blib/lib/HTML/FormHandler/Widget/Theme/Bootstrap.pm
Criterion Covered Total %
statement 4 4 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 6 7 85.7


line stmt bran cond sub pod time code
1             package HTML::FormHandler::Widget::Theme::Bootstrap;
2             # ABSTRACT: sample bootstrap theme
3             $HTML::FormHandler::Widget::Theme::Bootstrap::VERSION = '0.40067';
4              
5 4     4   5231 use Moose::Role;
  4         6  
  4         34  
6             with 'HTML::FormHandler::Widget::Theme::BootstrapFormMessages';
7              
8             after 'before_build' => sub {
9             my $self = shift;
10             $self->set_widget_wrapper('Bootstrap')
11             if $self->widget_wrapper eq 'Simple';
12             };
13              
14 4     4 0 1828 sub build_form_element_class { ['form-horizontal'] }
15              
16             1;
17              
18             __END__
19              
20             =pod
21              
22             =encoding UTF-8
23              
24             =head1 NAME
25              
26             HTML::FormHandler::Widget::Theme::Bootstrap - sample bootstrap theme
27              
28             =head1 VERSION
29              
30             version 0.40067
31              
32             =head1 SYNOPSIS
33              
34             Also see L<HTML::FormHandler::Manual::Rendering>.
35              
36             Sample Bootstrap theme role. Can be applied to your subclass of HTML::FormHandler.
37             Sets the widget wrapper to 'Bootstrap' and renders form messages using Bootstrap
38             formatting and classes.
39              
40             There is an example app using Bootstrap at http://github.com/gshank/formhandler-example.
41              
42             This is a lightweight example of what you could do in your own custom
43             Bootstrap theme. The heavy lifting is done by the Bootstrap wrapper,
44             L<HTML::FormHandler::Widget::Wrapper::Bootstrap>,
45             which you can use by itself in your form with:
46              
47             has '+widget_wrapper' => ( default => 'Bootstrap' );
48              
49             It also uses L<HTML::FormHandler::Widget::Theme::BootstrapFormMessages>
50             to render the form messages in a Bootstrap style:
51              
52             <div class="alert alert-error">
53             <span class="error_message">....</span>
54             </div>
55              
56             By default this does 'form-horizontal' with 'build_form_element_class'.
57             Implement your own sub to use 'form-vertical':
58              
59             sub build_form_element_class { ['form-vertical'] }
60              
61             =head1 AUTHOR
62              
63             FormHandler Contributors - see HTML::FormHandler
64              
65             =head1 COPYRIGHT AND LICENSE
66              
67             This software is copyright (c) 2016 by Gerda Shank.
68              
69             This is free software; you can redistribute it and/or modify it under
70             the same terms as the Perl 5 programming language system itself.
71              
72             =cut