| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package HTML::FormHandler::Widget::Theme::BootstrapFormMessages; | 
| 2 |  |  |  |  |  |  | # ABSTRACT: role to render form messages using Bootstrap styling | 
| 3 |  |  |  |  |  |  | $HTML::FormHandler::Widget::Theme::BootstrapFormMessages::VERSION = '0.40068'; | 
| 4 | 7 |  |  | 7 |  | 8787 | use Moose::Role; | 
|  | 7 |  |  |  |  | 20 |  | 
|  | 7 |  |  |  |  | 56 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | sub render_form_messages { | 
| 8 | 6 |  |  | 6 | 0 | 32 | my ( $self, $result ) = @_; | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 6 | 50 |  |  |  | 33 | return '' if $self->get_tag('no_form_message_div'); | 
| 11 |  |  |  |  |  |  |  | 
| 12 | 6 |  | 66 |  |  | 52 | $result ||= $self->result; | 
| 13 | 6 |  |  |  |  | 19 | my $output = ''; | 
| 14 | 6 | 100 | 66 |  |  | 226 | if ( $result->has_form_errors || $result->has_errors ) { | 
|  |  | 100 |  |  |  |  |  | 
| 15 | 1 |  |  |  |  | 5 | my $alert_error_class = $self->form_messages_alert_error_class; | 
| 16 | 1 |  |  |  |  | 5 | $output = qq{\n<div class="alert $alert_error_class">}; | 
| 17 | 1 |  |  |  |  | 29 | my $msg = $self->error_message; | 
| 18 | 1 |  | 50 |  |  | 7 | $msg ||= 'There were errors in your form'; | 
| 19 | 1 |  |  |  |  | 10 | $msg = $self->_localize($msg); | 
| 20 | 1 |  |  |  |  | 5 | $output .= qq{\n<span class="error_message">$msg</span>}; | 
| 21 |  |  |  |  |  |  | $output .= qq{\n<span class="error_message">$_</span>} | 
| 22 | 1 |  |  |  |  | 43 | for $result->all_form_errors; | 
| 23 | 1 |  |  |  |  | 4 | $output .= "\n</div>"; | 
| 24 |  |  |  |  |  |  | } | 
| 25 |  |  |  |  |  |  | elsif ( $result->validated ) { | 
| 26 | 1 |  |  |  |  | 32 | my $msg = $self->success_message; | 
| 27 | 1 |  | 50 |  |  | 7 | $msg ||= "Your form was successfully submitted"; | 
| 28 | 1 |  |  |  |  | 9 | $msg = $self->_localize($msg); | 
| 29 | 1 |  |  |  |  | 4 | $output = qq{\n<div class="alert alert-success">}; | 
| 30 | 1 |  |  |  |  | 5 | $output .= qq{\n<span>$msg</span>}; | 
| 31 | 1 |  |  |  |  | 3 | $output .= "\n</div>"; | 
| 32 |  |  |  |  |  |  | } | 
| 33 | 6 | 100 | 66 |  |  | 195 | if ( $self->has_info_message && $self->info_message ) { | 
| 34 | 1 |  |  |  |  | 24 | my $msg = $self->info_message; | 
| 35 | 1 |  |  |  |  | 16 | $msg = $self->_localize($msg); | 
| 36 | 1 |  |  |  |  | 4 | $output = qq{\n<div class="alert alert-info">}; | 
| 37 | 1 |  |  |  |  | 7 | $output .= qq{\n<span>$msg</span>}; | 
| 38 | 1 |  |  |  |  | 4 | $output .= "\n</div>"; | 
| 39 |  |  |  |  |  |  | } | 
| 40 | 6 |  |  |  |  | 35 | return $output; | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 1 |  |  | 1 | 0 | 3 | sub form_messages_alert_error_class { 'alert-error' } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | 1; | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | __END__ | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =pod | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | =encoding UTF-8 | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | =head1 NAME | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | HTML::FormHandler::Widget::Theme::BootstrapFormMessages - role to render form messages using Bootstrap styling | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =head1 VERSION | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | version 0.40068 | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | Role to render form messages using Bootstrap styling. | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head1 NAME | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | HTML::FormHandler::Widget::Theme::BootstrapFormMessages | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 AUTHOR | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | FormHandler Contributors - see HTML::FormHandler | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | This software is copyright (c) 2017 by Gerda Shank. | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 78 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | =cut |