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.40067'; |
4
|
4
|
|
|
4
|
|
5190
|
use Moose::Role; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with 'HTML::FormHandler::Render::Simple' => |
7
|
|
|
|
|
|
|
{ -excludes => [ 'render', 'wrap_field', 'render_end', 'render_start' ] }; |
8
|
4
|
|
|
4
|
|
13774
|
use HTML::FormHandler::Render::Util ('process_attrs'); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
24
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub render { |
12
|
3
|
|
|
3
|
0
|
910
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
|
|
13
|
my $output = $self->render_start; |
15
|
3
|
|
|
|
|
14
|
$output .= $self->render_form_errors; |
16
|
3
|
|
|
|
|
13
|
foreach my $field ( $self->sorted_fields ) { |
17
|
21
|
|
|
|
|
62
|
$output .= $self->render_field($field); |
18
|
|
|
|
|
|
|
} |
19
|
3
|
|
|
|
|
16
|
$output .= $self->render_end; |
20
|
3
|
|
|
|
|
80
|
return $output; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub render_start { |
24
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
22
|
my $attrs = process_attrs($self->attributes); |
27
|
3
|
|
|
|
|
15
|
return qq{<form$attrs><table>}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub render_form_errors { |
31
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
32
|
|
|
|
|
|
|
|
33
|
3
|
50
|
|
|
|
24
|
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
|
5
|
my $self = shift; |
43
|
3
|
|
|
|
|
6
|
my $output .= "</table>\n"; |
44
|
3
|
|
|
|
|
16
|
$output .= "</form>\n"; |
45
|
3
|
|
|
|
|
7
|
return $output; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub wrap_field { |
49
|
24
|
|
|
24
|
0
|
33
|
my ( $self, $field, $rendered_field ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
24
|
|
|
|
|
98
|
my $attrs = process_attrs($field->wrapper_attributes); |
52
|
24
|
|
|
|
|
48
|
my $output = qq{\n<tr$attrs>}; |
53
|
24
|
100
|
|
|
|
624
|
my $l_type = $field->widget eq 'Compound' ? 'legend' : 'label'; |
54
|
24
|
100
|
|
|
|
43
|
if ( $l_type eq 'label' ) { |
|
|
50
|
|
|
|
|
|
55
|
23
|
|
|
|
|
61
|
$output .= '<td>' . $self->render_label($field) . '</td>'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif ( $l_type eq 'legend' ) { |
58
|
1
|
|
|
|
|
6
|
$output .= '<td>' . $self->render_label($field) . '</td></tr>'; |
59
|
|
|
|
|
|
|
} |
60
|
24
|
100
|
|
|
|
48
|
if ( $l_type ne 'legend' ) { |
61
|
23
|
|
|
|
|
24
|
$output .= '<td>'; |
62
|
|
|
|
|
|
|
} |
63
|
24
|
|
|
|
|
27
|
$output .= $rendered_field; |
64
|
24
|
|
|
|
|
101
|
$output .= qq{\n<span class="error_message">$_</span>} for $field->all_errors; |
65
|
24
|
100
|
|
|
|
41
|
if ( $l_type ne 'legend' ) { |
66
|
23
|
|
|
|
|
35
|
$output .= "</td></tr>\n"; |
67
|
|
|
|
|
|
|
} |
68
|
24
|
|
|
|
|
92
|
return $output; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
4
|
|
1833
|
use namespace::autoclean; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
31
|
|
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.40067 |
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) 2016 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 |