| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::FormHandler::Render::Table; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: render a form with a table layout |
|
3
|
|
|
|
|
|
|
$HTML::FormHandler::Render::Table::VERSION = '0.40068'; |
|
4
|
4
|
|
|
4
|
|
7500
|
use Moose::Role; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
34
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with 'HTML::FormHandler::Render::Simple' => |
|
7
|
|
|
|
|
|
|
{ -excludes => [ 'render', 'wrap_field', 'render_end', 'render_start' ] }; |
|
8
|
4
|
|
|
4
|
|
20922
|
use HTML::FormHandler::Render::Util ('process_attrs'); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
31
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub render { |
|
12
|
3
|
|
|
3
|
0
|
1022
|
my $self = shift; |
|
13
|
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
21
|
my $output = $self->render_start; |
|
15
|
3
|
|
|
|
|
18
|
$output .= $self->render_form_errors; |
|
16
|
3
|
|
|
|
|
17
|
foreach my $field ( $self->sorted_fields ) { |
|
17
|
21
|
|
|
|
|
93
|
$output .= $self->render_field($field); |
|
18
|
|
|
|
|
|
|
} |
|
19
|
3
|
|
|
|
|
21
|
$output .= $self->render_end; |
|
20
|
3
|
|
|
|
|
89
|
return $output; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub render_start { |
|
24
|
3
|
|
|
3
|
0
|
9
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
50
|
my $attrs = process_attrs($self->attributes); |
|
27
|
3
|
|
|
|
|
20
|
return qq{<form$attrs><table>}; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub render_form_errors { |
|
31
|
3
|
|
|
3
|
0
|
10
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
|
|
33
|
3
|
50
|
|
|
|
34
|
return '' unless $self->has_form_errors; |
|
34
|
0
|
|
|
|
|
0
|
my $output = "\n<tr class=\"form_errors\"><td colspan=\"2\">"; |
|
35
|
|
|
|
|
|
|
$output .= qq{\n<span class="error_message">$_</span>} |
|
36
|
0
|
|
|
|
|
0
|
for $self->all_form_errors; |
|
37
|
0
|
|
|
|
|
0
|
$output .= "\n</td></tr>"; |
|
38
|
0
|
|
|
|
|
0
|
return $output; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub render_end { |
|
42
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
|
43
|
3
|
|
|
|
|
19
|
my $output .= "</table>\n"; |
|
44
|
3
|
|
|
|
|
9
|
$output .= "</form>\n"; |
|
45
|
3
|
|
|
|
|
9
|
return $output; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub wrap_field { |
|
49
|
24
|
|
|
24
|
0
|
62
|
my ( $self, $field, $rendered_field ) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
24
|
|
|
|
|
112
|
my $attrs = process_attrs($field->wrapper_attributes); |
|
52
|
24
|
|
|
|
|
73
|
my $output = qq{\n<tr$attrs>}; |
|
53
|
24
|
100
|
|
|
|
663
|
my $l_type = $field->widget eq 'Compound' ? 'legend' : 'label'; |
|
54
|
24
|
100
|
|
|
|
65
|
if ( $l_type eq 'label' ) { |
|
|
|
50
|
|
|
|
|
|
|
55
|
23
|
|
|
|
|
91
|
$output .= '<td>' . $self->render_label($field) . '</td>'; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
elsif ( $l_type eq 'legend' ) { |
|
58
|
1
|
|
|
|
|
5
|
$output .= '<td>' . $self->render_label($field) . '</td></tr>'; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
24
|
100
|
|
|
|
78
|
if ( $l_type ne 'legend' ) { |
|
61
|
23
|
|
|
|
|
49
|
$output .= '<td>'; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
24
|
|
|
|
|
50
|
$output .= $rendered_field; |
|
64
|
24
|
|
|
|
|
134
|
$output .= qq{\n<span class="error_message">$_</span>} for $field->all_errors; |
|
65
|
24
|
100
|
|
|
|
67
|
if ( $l_type ne 'legend' ) { |
|
66
|
23
|
|
|
|
|
56
|
$output .= "</td></tr>\n"; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
24
|
|
|
|
|
126
|
return $output; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
4
|
|
|
4
|
|
2320
|
use namespace::autoclean; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
40
|
|
|
72
|
|
|
|
|
|
|
1; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=encoding UTF-8 |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
HTML::FormHandler::Render::Table - render a form with a table layout |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VERSION |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
version 0.40068 |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Include this role in a form: |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
package MyApp::Form::User; |
|
93
|
|
|
|
|
|
|
use Moose; |
|
94
|
|
|
|
|
|
|
with 'HTML::FormHandler::Render::Table'; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Use in a template: |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
[% form.render %] |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
FormHandler Contributors - see HTML::FormHandler |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Gerda Shank. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
109
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |