line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::FormHandler::Widget::Wrapper::Simple; |
2
|
|
|
|
|
|
|
# ABSTRACT: simple field wrapper |
3
|
|
|
|
|
|
|
$HTML::FormHandler::Widget::Wrapper::Simple::VERSION = '0.40068'; |
4
|
128
|
|
|
128
|
|
86586
|
use Moose::Role; |
|
128
|
|
|
|
|
384
|
|
|
128
|
|
|
|
|
2730
|
|
5
|
128
|
|
|
128
|
|
679788
|
use namespace::autoclean; |
|
128
|
|
|
|
|
389
|
|
|
128
|
|
|
|
|
2908
|
|
6
|
128
|
|
|
128
|
|
9643
|
use HTML::FormHandler::Render::Util ('process_attrs'); |
|
128
|
|
|
|
|
359
|
|
|
128
|
|
|
|
|
1090
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'HTML::FormHandler::Widget::Wrapper::Base'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub wrap_field { |
13
|
425
|
|
|
425
|
0
|
1504
|
my ( $self, $result, $rendered_widget ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
425
|
|
|
|
|
796
|
my $output; |
16
|
|
|
|
|
|
|
# get wrapper tag if set |
17
|
425
|
|
50
|
|
|
2212
|
my $label_tag = $self->label_tag || ''; |
18
|
425
|
|
|
|
|
902
|
my $wrapper_tag; |
19
|
425
|
100
|
|
|
|
12298
|
if( $self->do_wrapper ) { |
20
|
376
|
|
|
|
|
1220
|
$output .= $self->get_tag('before_wrapper'); |
21
|
376
|
|
|
|
|
1234
|
$wrapper_tag = $self->get_tag('wrapper_tag'); |
22
|
|
|
|
|
|
|
# default wrapper tags |
23
|
376
|
100
|
66
|
|
|
2346
|
$wrapper_tag ||= $self->has_flag('is_repeatable') ? 'fieldset' : 'div'; |
24
|
|
|
|
|
|
|
# get attribute string |
25
|
376
|
|
|
|
|
2038
|
my $attrs = process_attrs( $self->wrapper_attributes($result) ); |
26
|
|
|
|
|
|
|
# write wrapper tag |
27
|
376
|
|
|
|
|
1398
|
$output .= qq{\n<$wrapper_tag$attrs>}; |
28
|
376
|
100
|
|
|
|
1649
|
$label_tag = 'legend' if $wrapper_tag eq 'fieldset'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
# write label; special processing for checkboxes |
31
|
425
|
100
|
|
|
|
14487
|
$rendered_widget = $self->wrap_checkbox($result, $rendered_widget) |
32
|
|
|
|
|
|
|
if ( lc $self->widget eq 'checkbox' ); |
33
|
424
|
100
|
|
|
|
11686
|
$output .= "\n" . $self->do_render_label($result, $label_tag) |
34
|
|
|
|
|
|
|
if $self->do_label; |
35
|
|
|
|
|
|
|
# append 'before_element' |
36
|
424
|
|
|
|
|
1577
|
$output .= $self->get_tag('before_element'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# start controls div |
39
|
424
|
100
|
|
|
|
1500
|
if ( $self->get_tag('controls_div') ) { |
|
|
100
|
|
|
|
|
|
40
|
1
|
|
|
|
|
3
|
$output .= qq{\n<div class="controls">}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ( $self->has_element_wrapper_class ) { |
43
|
1
|
|
|
|
|
11
|
my $ew_attr = $self->element_wrapper_attributes($result); |
44
|
1
|
|
|
|
|
4
|
my $element_wrapper_attrs = process_attrs( $ew_attr ); |
45
|
1
|
|
|
|
|
4
|
$output .= qq{\n<div$element_wrapper_attrs>}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# the input element itself |
49
|
424
|
|
|
|
|
1310
|
$output .= "\n$rendered_widget"; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# close controls div |
52
|
424
|
100
|
100
|
|
|
1497
|
if ( $self->get_tag('controls_div') || $self->has_element_wrapper_class ) { |
53
|
|
|
|
|
|
|
# end control div |
54
|
2
|
|
|
|
|
6
|
$output .= "\n</div>"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# the 'after_element' |
58
|
424
|
|
|
|
|
1463
|
$output .= $self->get_tag('after_element'); |
59
|
|
|
|
|
|
|
# the error messages |
60
|
424
|
50
|
|
|
|
1388
|
unless( $self->get_tag('no_errors') ) { |
61
|
424
|
|
50
|
|
|
1357
|
my $error_class = $self->get_tag('error_class') || 'error_message'; |
62
|
|
|
|
|
|
|
$output .= qq{\n<span class="$error_class">$_</span>} |
63
|
424
|
|
|
|
|
14794
|
for $result->all_errors; |
64
|
|
|
|
|
|
|
# warnings (incompletely implemented - only on field itself) |
65
|
424
|
|
50
|
|
|
1426
|
my $warning_class = $self->get_tag('warning_class') || 'warning_message'; |
66
|
|
|
|
|
|
|
$output .= qq{\n<span class="warning_message">$_</span>} |
67
|
424
|
|
|
|
|
14793
|
for $result->all_warnings; |
68
|
|
|
|
|
|
|
} |
69
|
424
|
100
|
|
|
|
11577
|
if( $self->do_wrapper ) { |
70
|
375
|
|
|
|
|
1094
|
$output .= "\n</$wrapper_tag>"; |
71
|
375
|
|
|
|
|
1198
|
$output .= $self->get_tag('after_wrapper'); |
72
|
|
|
|
|
|
|
} |
73
|
424
|
|
|
|
|
3022
|
return "$output"; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=pod |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=encoding UTF-8 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
HTML::FormHandler::Widget::Wrapper::Simple - simple field wrapper |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
version 0.40068 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This is the default wrapper role. It will be installed if |
96
|
|
|
|
|
|
|
no other wrapper is specified and widget_wrapper is not set to |
97
|
|
|
|
|
|
|
'none'. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Relevant field flags: |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
do_wrapper |
102
|
|
|
|
|
|
|
do_label |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
If 'do_label' is set and not 'do_wrapper', only the label plus |
105
|
|
|
|
|
|
|
the form element will be rendered. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Supported 'tags', all set via the 'tags' hashref on the field: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
wrapper_tag -- the tag to use in the wrapper, default 'div' |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
label_tag -- tag to use for label (default 'label') |
112
|
|
|
|
|
|
|
label_after -- string to append to label, for example ': ' to append a colon |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
before_element -- string that goes right before the element |
115
|
|
|
|
|
|
|
after_element -- string that goes right after the element |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
no_errors -- don't issue error messages on the field |
118
|
|
|
|
|
|
|
error_class -- class for error messages (default 'error_message') |
119
|
|
|
|
|
|
|
warning_class -- class for warning messages (default 'warning_message' ) |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
no_wrapped_label -- for checkboxes. Don't provide an inner wrapped label |
122
|
|
|
|
|
|
|
(from Base wrapper) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Example: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
has_field 'foo' => ( tags => { wrapper_tag => 'span', no_errors => 1 } ); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gerda Shank. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |