line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
7
|
|
|
7
|
|
46
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
254
|
|
4
|
7
|
|
|
7
|
|
35
|
use 5.008_005; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
152
|
|
5
|
7
|
|
|
7
|
|
108
|
|
|
7
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
use HTML::FormBuilder::Field; |
7
|
7
|
|
|
7
|
|
3093
|
use Carp; |
|
7
|
|
|
|
|
28
|
|
|
7
|
|
|
|
|
247
|
|
8
|
7
|
|
|
7
|
|
53
|
use Scalar::Util qw(weaken blessed); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
412
|
|
9
|
7
|
|
|
7
|
|
44
|
|
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
317
|
|
10
|
|
|
|
|
|
|
use Moo; |
11
|
7
|
|
|
7
|
|
46
|
use namespace::clean; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
33
|
|
12
|
7
|
|
|
7
|
|
2472
|
extends qw(HTML::FormBuilder::Base); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
65
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.13'; ## VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has data => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => sub { |
19
|
|
|
|
|
|
|
my $data = shift; |
20
|
|
|
|
|
|
|
croak('data should be a hashref') unless ref($data) eq 'HASH'; |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
default => sub { |
23
|
|
|
|
|
|
|
{}; |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has fields => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => sub { |
30
|
|
|
|
|
|
|
my $fields = shift; |
31
|
|
|
|
|
|
|
croak('fields should be an arrayref') unless ref($fields) eq 'ARRAY'; |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
default => sub { |
34
|
|
|
|
|
|
|
[]; |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
my $_args = shift; |
40
|
97
|
|
|
97
|
1
|
1598
|
|
41
|
97
|
|
|
|
|
139
|
my $field = HTML::FormBuilder::Field->new( |
42
|
|
|
|
|
|
|
data => $_args, |
43
|
97
|
|
|
|
|
1673
|
classes => $self->classes, |
44
|
|
|
|
|
|
|
localize => $self->localize |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
push @{$self->{'fields'}}, $field; |
47
|
|
|
|
|
|
|
|
48
|
97
|
|
|
|
|
600
|
return $field; |
|
97
|
|
|
|
|
215
|
|
49
|
|
|
|
|
|
|
} |
50
|
97
|
|
|
|
|
198
|
|
51
|
|
|
|
|
|
|
my ($self, @field_args) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
for my $field_arg (@field_args) { |
54
|
1
|
|
|
1
|
1
|
1328
|
$self->add_field($field_arg); |
55
|
|
|
|
|
|
|
} |
56
|
1
|
|
|
|
|
4
|
return scalar @field_args; |
57
|
2
|
|
|
|
|
6
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
7
|
##################################################################### |
60
|
|
|
|
|
|
|
# Usage : generate the form content for a fieldset |
61
|
|
|
|
|
|
|
# Purpose : check and parse the parameters and generate the form |
62
|
|
|
|
|
|
|
# properly |
63
|
|
|
|
|
|
|
# Returns : a piece of form HTML for a fieldset |
64
|
|
|
|
|
|
|
# Parameters : fieldset |
65
|
|
|
|
|
|
|
# Comments : |
66
|
|
|
|
|
|
|
# See Also : |
67
|
|
|
|
|
|
|
##################################################################### |
68
|
|
|
|
|
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $data = $self->{data}; |
71
|
|
|
|
|
|
|
|
72
|
18
|
|
|
18
|
1
|
34
|
#FIXME this attribute should be deleted, or it will emit to the html code |
73
|
|
|
|
|
|
|
my $fieldset_group = $data->{'group'}; |
74
|
18
|
|
|
|
|
49
|
my $stacked = defined $data->{'stacked'} ? $data->{'stacked'} : 1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
if (not $fieldset_group) { |
77
|
18
|
|
|
|
|
47
|
$fieldset_group = 'no-group'; |
78
|
18
|
100
|
|
|
|
46
|
} |
79
|
|
|
|
|
|
|
|
80
|
18
|
100
|
|
|
|
45
|
my $fieldset_html = $self->_build_fieldset_foreword(); |
81
|
17
|
|
|
|
|
33
|
|
82
|
|
|
|
|
|
|
my $input_fields_html = ''; |
83
|
|
|
|
|
|
|
|
84
|
18
|
|
|
|
|
45
|
foreach my $input_field (@{$self->{'fields'}}) { |
85
|
|
|
|
|
|
|
$input_fields_html .= $input_field->build({stacked => $stacked}); |
86
|
18
|
|
|
|
|
37
|
} |
87
|
|
|
|
|
|
|
|
88
|
18
|
|
|
|
|
26
|
if ($stacked == 0) { |
|
18
|
|
|
|
|
42
|
|
89
|
71
|
|
|
|
|
246
|
$input_fields_html = $self->_build_element_and_attributes('div', {class => $self->{classes}{'no_stack_field_parent'}}, $input_fields_html); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
18
|
100
|
|
|
|
50
|
$fieldset_html .= $input_fields_html; |
93
|
1
|
|
|
|
|
6
|
|
94
|
|
|
|
|
|
|
# message at the bottom of the fieldset |
95
|
|
|
|
|
|
|
if (defined $data->{'footer'}) { |
96
|
18
|
|
|
|
|
59
|
my $footer = delete $data->{'footer'}; |
97
|
|
|
|
|
|
|
$fieldset_html .= qq{<div class="$self->{classes}{fieldset_footer}">$footer</div>}; |
98
|
|
|
|
|
|
|
} |
99
|
18
|
100
|
|
|
|
49
|
|
100
|
1
|
|
|
|
|
3
|
$fieldset_html = $self->_build_element_and_attributes('fieldset', $data, $fieldset_html); |
101
|
1
|
|
|
|
|
6
|
|
102
|
|
|
|
|
|
|
if ( |
103
|
|
|
|
|
|
|
(not $data->{'id'} or $data->{'id'} ne 'formlayout') |
104
|
18
|
|
|
|
|
74
|
and (not $data->{'class'} |
105
|
|
|
|
|
|
|
or $data->{'class'} !~ /no-wrap|invisible/)) |
106
|
18
|
50
|
33
|
|
|
148
|
{ |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
107
|
|
|
|
|
|
|
$fieldset_html = $self->_wrap_fieldset($fieldset_html); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
return ($fieldset_group, $fieldset_html); |
111
|
18
|
|
|
|
|
55
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
##################################################################### |
114
|
18
|
|
|
|
|
69
|
# Usage : generate the form content for a fieldset foreword thing |
115
|
|
|
|
|
|
|
# Purpose : check and parse the parameters and generate the form |
116
|
|
|
|
|
|
|
# properly |
117
|
|
|
|
|
|
|
# Returns : a piece of form HTML code for a fieldset foreword |
118
|
|
|
|
|
|
|
# Parameters : input_field, stacked |
119
|
|
|
|
|
|
|
# Comments : |
120
|
|
|
|
|
|
|
# See Also : |
121
|
|
|
|
|
|
|
##################################################################### |
122
|
|
|
|
|
|
|
my $self = shift; |
123
|
|
|
|
|
|
|
my $data = $self->{data}; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# fieldset legend |
126
|
|
|
|
|
|
|
my $legend = ''; |
127
|
18
|
|
|
18
|
|
29
|
if (defined $data->{'legend'}) { |
128
|
18
|
|
|
|
|
34
|
$legend = qq{<legend>$data->{legend}</legend>}; |
129
|
|
|
|
|
|
|
undef $data->{'legend'}; |
130
|
|
|
|
|
|
|
} |
131
|
18
|
|
|
|
|
27
|
|
132
|
18
|
100
|
|
|
|
44
|
# header at the top of the fieldset |
133
|
1
|
|
|
|
|
5
|
my $header = ''; |
134
|
1
|
|
|
|
|
2
|
if (defined $data->{'header'}) { |
135
|
|
|
|
|
|
|
$header = qq{<h2>$data->{header}</h2>}; |
136
|
|
|
|
|
|
|
undef $data->{'header'}; |
137
|
|
|
|
|
|
|
} |
138
|
18
|
|
|
|
|
40
|
|
139
|
18
|
100
|
|
|
|
38
|
# message at the top of the fieldset |
140
|
1
|
|
|
|
|
4
|
my $comment = ''; |
141
|
1
|
|
|
|
|
2
|
if (defined $data->{'comment'}) { |
142
|
|
|
|
|
|
|
$comment = qq{<div class="$self->{classes}{comment}"><p>$data->{comment}</p></div>}; |
143
|
|
|
|
|
|
|
undef $data->{'comment'}; |
144
|
|
|
|
|
|
|
} |
145
|
18
|
|
|
|
|
30
|
|
146
|
18
|
100
|
|
|
|
44
|
return $legend . $header . $comment; |
147
|
1
|
|
|
|
|
4
|
} |
148
|
1
|
|
|
|
|
2
|
|
149
|
|
|
|
|
|
|
##################################################################### |
150
|
|
|
|
|
|
|
# Usage : $self->_wrap_fieldset($fieldset_html) |
151
|
18
|
|
|
|
|
53
|
# Purpose : wrap fieldset html by template |
152
|
|
|
|
|
|
|
# Returns : HTML |
153
|
|
|
|
|
|
|
# Comments : |
154
|
|
|
|
|
|
|
# See Also : |
155
|
|
|
|
|
|
|
##################################################################### |
156
|
|
|
|
|
|
|
my ($self, $fieldset_html) = @_; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
my $fieldset_template = <<EOF; |
159
|
|
|
|
|
|
|
<div class="rbox form"> |
160
|
|
|
|
|
|
|
<div class="rbox-wrap"> |
161
|
|
|
|
|
|
|
$fieldset_html |
162
|
18
|
|
|
18
|
|
45
|
<span class="tl"> </span><span class="tr"> </span><span class="bl"> </span><span class="br"> </span> |
163
|
|
|
|
|
|
|
</div> |
164
|
18
|
|
|
|
|
97
|
</div> |
165
|
|
|
|
|
|
|
EOF |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
return $fieldset_template; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 NAME |
173
|
18
|
|
|
|
|
62
|
|
174
|
|
|
|
|
|
|
HTML::FormBuilder::FieldSet - FieldSet container used by HTML::FormBuilder |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 SYNOPSIS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
my $form = HTML::FormBuilder->new(data => {id => 'testform}); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
my $fieldset = $form->add_fieldset({id => 'fieldset1'}); |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
$fieldset->add_field({input => {type => 'text', value => 'Join'}}); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
$form->add_field($fieldset_index, {input => {type => 'text', value => 'Join'}}); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head1 Attributes |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 fields |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
The fields included by this fieldset. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head1 Methods |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head2 build |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
my ($fieldset_group, $fieldset_html) = $fieldset->build(); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head2 add_field |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
$fieldset->add_field({input => {type => 'text', value => 'name'}}); |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
append the field into fieldset and return that field |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 add_fields |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
$fieldset->add_fields({input => {type => 'text', value => 'name'}},{input => {type => 'text', value => 'address'}}); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
append fields into fieldset and return the number of fields added. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 data |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 AUTHOR |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Chylli L<mailto:chylli@binary.com> |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Fayland Lam L<mailto:fayland@binary.com> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Tee Shuwn Yuan L<mailto:shuwnyuan@binary.com> |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=cut |