| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Rose::HTML::Form::Field::Checkbox; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
210346
|
use strict; |
|
|
6
|
|
|
|
|
38
|
|
|
|
6
|
|
|
|
|
209
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
35
|
use base 'Rose::HTML::Form::Field::OnOff::Checkable'; |
|
|
6
|
|
|
|
|
22
|
|
|
|
6
|
|
|
|
|
2619
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.617'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->delete_valid_html_attrs(qw(ismap usemap alt src)); |
|
10
|
|
|
|
|
|
|
__PACKAGE__->required_html_attr_value(type => 'checkbox'); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub html_checkbox |
|
13
|
|
|
|
|
|
|
{ |
|
14
|
124
|
|
|
124
|
1
|
860
|
my($self) = shift; |
|
15
|
124
|
|
|
|
|
376
|
$self->html_attr(checked => $self->checked); |
|
16
|
124
|
|
|
|
|
404
|
return $self->SUPER::html_field(@_); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub xhtml_checkbox |
|
20
|
|
|
|
|
|
|
{ |
|
21
|
69
|
|
|
69
|
1
|
503
|
my($self) = shift; |
|
22
|
69
|
|
|
|
|
226
|
$self->html_attr(checked => $self->checked); |
|
23
|
69
|
|
|
|
|
226
|
return $self->SUPER::xhtml_field(@_); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub html_field |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
121
|
|
|
121
|
1
|
726
|
my($self) = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
121
|
|
50
|
|
|
281
|
return ($self->html_prefix || '') . |
|
|
|
|
50
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->html_checkbox . ' ' . $self->html_label . |
|
32
|
|
|
|
|
|
|
($self->html_suffix || ''); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub xhtml_field |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
66
|
|
|
66
|
1
|
132
|
my($self) = shift; |
|
38
|
66
|
|
50
|
|
|
157
|
return ($self->html_prefix || '') . |
|
|
|
|
50
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$self->xhtml_checkbox . ' ' . $self->html_label . |
|
40
|
|
|
|
|
|
|
($self->html_suffix || ''); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Checkbox - Object representation of a single checkbox field in an HTML form. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$field = |
|
54
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Checkbox->new( |
|
55
|
|
|
|
|
|
|
label => 'Run tests', |
|
56
|
|
|
|
|
|
|
name => 'tests', |
|
57
|
|
|
|
|
|
|
value => 'yes'); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$checked = $field->is_checked; # false |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$field->checked(1); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
print $field->html; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
... |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L<Rose::HTML::Form::Field::Checkbox> is an object representation of a single checkbox field in an HTML form. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This class inherits from, and follows the conventions of, L<Rose::HTML::Form::Field>. Inherited methods that are not overridden will not be documented a second time here. See the L<Rose::HTML::Form::Field> documentation for more information. |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 HTML ATTRIBUTES |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Valid attributes: |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
accept |
|
78
|
|
|
|
|
|
|
accesskey |
|
79
|
|
|
|
|
|
|
checked |
|
80
|
|
|
|
|
|
|
class |
|
81
|
|
|
|
|
|
|
dir |
|
82
|
|
|
|
|
|
|
disabled |
|
83
|
|
|
|
|
|
|
id |
|
84
|
|
|
|
|
|
|
lang |
|
85
|
|
|
|
|
|
|
maxlength |
|
86
|
|
|
|
|
|
|
name |
|
87
|
|
|
|
|
|
|
onblur |
|
88
|
|
|
|
|
|
|
onchange |
|
89
|
|
|
|
|
|
|
onclick |
|
90
|
|
|
|
|
|
|
ondblclick |
|
91
|
|
|
|
|
|
|
onfocus |
|
92
|
|
|
|
|
|
|
onkeydown |
|
93
|
|
|
|
|
|
|
onkeypress |
|
94
|
|
|
|
|
|
|
onkeyup |
|
95
|
|
|
|
|
|
|
onmousedown |
|
96
|
|
|
|
|
|
|
onmousemove |
|
97
|
|
|
|
|
|
|
onmouseout |
|
98
|
|
|
|
|
|
|
onmouseover |
|
99
|
|
|
|
|
|
|
onmouseup |
|
100
|
|
|
|
|
|
|
onselect |
|
101
|
|
|
|
|
|
|
readonly |
|
102
|
|
|
|
|
|
|
size |
|
103
|
|
|
|
|
|
|
style |
|
104
|
|
|
|
|
|
|
tabindex |
|
105
|
|
|
|
|
|
|
title |
|
106
|
|
|
|
|
|
|
type |
|
107
|
|
|
|
|
|
|
value |
|
108
|
|
|
|
|
|
|
xml:lang |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Required attributes (default values in parentheses): |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
type (checkbox) |
|
113
|
|
|
|
|
|
|
value |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Boolean attributes: |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
checked |
|
118
|
|
|
|
|
|
|
disabled |
|
119
|
|
|
|
|
|
|
readonly |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item B<new PARAMS> |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Constructs a new L<Rose::HTML::Form::Field::Checkbox> object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=back |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=over 4 |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item B<checked [BOOL]> |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Check or uncheck the checkbox by passing a boolean value. If BOOL is true, the checkbox will be checked. If it is false, it will be unchecked. Returns true if the checkbox is checked, false otherwise. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item B<hidden [BOOL]> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Get or set a boolean value that indicates whether or not this checkbox will be shown in its parent L<checkbox group|Rose::HTML::Form::Field::CheckboxGroup>. Setting it to true also sets L<checked|/checked> to false. |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item B<hide> |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Calls L<hidden|/hidden>, passing a true value. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item B<html_checkbox> |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Returns the HTML serialization of the checkbox field only (i.e., without any label or error message) |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item B<is_checked> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Returns true if the checkbox is checked, false otherwise. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item B<is_on> |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Simply calls L<is_checked|/is_checked>. This method exists for API uniformity between radio buttons and checkboxes. |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item B<show> |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Calls L<hidden|/hidden>, passing a false value. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item B<value [VALUE]> |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Gets or sets the value of the "value" HTML attribute. |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item B<xhtml_checkbox> |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Returns the XHTML serialization of the checkbox field only (i.e., without any label or error message) |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item B<label_object> |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns the object representing the L<label|Rose::HTML::Label> for the checkbox. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Example: |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
$field = |
|
178
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Checkbox->new( |
|
179
|
|
|
|
|
|
|
label => 'Run tests', |
|
180
|
|
|
|
|
|
|
name => 'tests', |
|
181
|
|
|
|
|
|
|
value => 'yes'); |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
$field->label_object->add_class('checkbox_label'); |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 AUTHOR |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 LICENSE |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Copyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |