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.40067'; |
4
|
126
|
|
|
126
|
|
65998
|
use Moose::Role; |
|
126
|
|
|
|
|
211
|
|
|
126
|
|
|
|
|
750
|
|
5
|
126
|
|
|
126
|
|
420332
|
use namespace::autoclean; |
|
126
|
|
|
|
|
204
|
|
|
126
|
|
|
|
|
771
|
|
6
|
126
|
|
|
126
|
|
6500
|
use HTML::FormHandler::Render::Util ('process_attrs'); |
|
126
|
|
|
|
|
194
|
|
|
126
|
|
|
|
|
807
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
with 'HTML::FormHandler::Widget::Wrapper::Base'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub wrap_field { |
13
|
422
|
|
|
422
|
0
|
556
|
my ( $self, $result, $rendered_widget ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
422
|
|
|
|
|
1133
|
my $output; |
16
|
|
|
|
|
|
|
# get wrapper tag if set |
17
|
422
|
|
50
|
|
|
1657
|
my $label_tag = $self->label_tag || ''; |
18
|
422
|
|
|
|
|
433
|
my $wrapper_tag; |
19
|
422
|
100
|
|
|
|
11169
|
if( $self->do_wrapper ) { |
20
|
373
|
|
|
|
|
794
|
$output .= $self->get_tag('before_wrapper'); |
21
|
373
|
|
|
|
|
815
|
$wrapper_tag = $self->get_tag('wrapper_tag'); |
22
|
|
|
|
|
|
|
# default wrapper tags |
23
|
373
|
100
|
66
|
|
|
1549
|
$wrapper_tag ||= $self->has_flag('is_repeatable') ? 'fieldset' : 'div'; |
24
|
|
|
|
|
|
|
# get attribute string |
25
|
373
|
|
|
|
|
1350
|
my $attrs = process_attrs( $self->wrapper_attributes($result) ); |
26
|
|
|
|
|
|
|
# write wrapper tag |
27
|
373
|
|
|
|
|
922
|
$output .= qq{\n<$wrapper_tag$attrs>}; |
28
|
373
|
100
|
|
|
|
806
|
$label_tag = 'legend' if $wrapper_tag eq 'fieldset'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
# write label; special processing for checkboxes |
31
|
422
|
100
|
|
|
|
11995
|
$rendered_widget = $self->wrap_checkbox($result, $rendered_widget) |
32
|
|
|
|
|
|
|
if ( lc $self->widget eq 'checkbox' ); |
33
|
421
|
100
|
|
|
|
10578
|
$output .= "\n" . $self->do_render_label($result, $label_tag) |
34
|
|
|
|
|
|
|
if $self->do_label; |
35
|
|
|
|
|
|
|
# append 'before_element' |
36
|
421
|
|
|
|
|
1002
|
$output .= $self->get_tag('before_element'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# start controls div |
39
|
421
|
100
|
|
|
|
882
|
if ( $self->get_tag('controls_div') ) { |
|
|
100
|
|
|
|
|
|
40
|
1
|
|
|
|
|
1
|
$output .= qq{\n<div class="controls">}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ( $self->has_element_wrapper_class ) { |
43
|
1
|
|
|
|
|
10
|
my $ew_attr = $self->element_wrapper_attributes($result); |
44
|
1
|
|
|
|
|
4
|
my $element_wrapper_attrs = process_attrs( $ew_attr ); |
45
|
1
|
|
|
|
|
5
|
$output .= qq{\n<div$element_wrapper_attrs>}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# the input element itself |
49
|
421
|
|
|
|
|
882
|
$output .= "\n$rendered_widget"; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# close controls div |
52
|
421
|
100
|
100
|
|
|
898
|
if ( $self->get_tag('controls_div') || $self->has_element_wrapper_class ) { |
53
|
|
|
|
|
|
|
# end control div |
54
|
2
|
|
|
|
|
4
|
$output .= "\n</div>"; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# the 'after_element' |
58
|
421
|
|
|
|
|
961
|
$output .= $self->get_tag('after_element'); |
59
|
|
|
|
|
|
|
# the error messages |
60
|
421
|
50
|
|
|
|
870
|
unless( $self->get_tag('no_errors') ) { |
61
|
421
|
|
50
|
|
|
850
|
my $error_class = $self->get_tag('error_class') || 'error_message'; |
62
|
|
|
|
|
|
|
$output .= qq{\n<span class="$error_class">$_</span>} |
63
|
421
|
|
|
|
|
13446
|
for $result->all_errors; |
64
|
|
|
|
|
|
|
# warnings (incompletely implemented - only on field itself) |
65
|
421
|
|
50
|
|
|
872
|
my $warning_class = $self->get_tag('warning_class') || 'warning_message'; |
66
|
|
|
|
|
|
|
$output .= qq{\n<span class="warning_message">$_</span>} |
67
|
421
|
|
|
|
|
13453
|
for $result->all_warnings; |
68
|
|
|
|
|
|
|
} |
69
|
421
|
100
|
|
|
|
10176
|
if( $self->do_wrapper ) { |
70
|
372
|
|
|
|
|
659
|
$output .= "\n</$wrapper_tag>"; |
71
|
372
|
|
|
|
|
776
|
$output .= $self->get_tag('after_wrapper'); |
72
|
|
|
|
|
|
|
} |
73
|
421
|
|
|
|
|
2140
|
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.40067 |
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) 2016 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 |