line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
11
|
|
|
11
|
|
84739
|
|
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
289
|
|
4
|
|
|
|
|
|
|
use Rose::HTML::Form::Field::Option::Container; |
5
|
11
|
|
|
11
|
|
738
|
# XXX: Use runtime inheritance here to avoid race in circular dependency |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
128
|
|
6
|
|
|
|
|
|
|
our @ISA = qw(Rose::HTML::Form::Field::Option::Container); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Rose::Object::MakeMethods::Generic |
9
|
|
|
|
|
|
|
( |
10
|
|
|
|
|
|
|
scalar => 'name', |
11
|
11
|
|
|
|
|
66
|
boolean => 'multiple', |
12
|
|
|
|
|
|
|
); |
13
|
11
|
|
|
11
|
|
58
|
|
|
11
|
|
|
|
|
18
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.606'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
__PACKAGE__->add_required_html_attrs( |
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
label => '', |
19
|
|
|
|
|
|
|
}); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->add_boolean_html_attrs('disabled'); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->delete_valid_html_attrs(qw( |
24
|
|
|
|
|
|
|
name |
25
|
|
|
|
|
|
|
value |
26
|
|
|
|
|
|
|
onblur |
27
|
|
|
|
|
|
|
onfocus |
28
|
|
|
|
|
|
|
accesskey |
29
|
|
|
|
|
|
|
tabindex)); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
1
|
0
|
|
33
|
66
|
|
|
66
|
1
|
293
|
|
34
|
32
|
|
|
32
|
1
|
139
|
|
35
|
|
|
|
|
|
|
{ |
36
|
11
|
|
|
11
|
1
|
82
|
my($self) = shift; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
1
|
3
|
if(@_) |
39
|
1
|
|
|
1
|
1
|
4
|
{ |
40
|
|
|
|
|
|
|
my $bool = shift; |
41
|
6
|
|
|
6
|
0
|
53
|
|
42
|
|
|
|
|
|
|
$self->SUPER::hidden($bool); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
foreach my $option ($self->options) |
45
|
34
|
|
|
34
|
0
|
53
|
{ |
46
|
|
|
|
|
|
|
$option->hidden($bool); |
47
|
34
|
100
|
|
|
|
65
|
} |
48
|
|
|
|
|
|
|
} |
49
|
6
|
|
|
|
|
10
|
|
50
|
|
|
|
|
|
|
return $self->SUPER::hidden(@_); |
51
|
6
|
|
|
|
|
18
|
} |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
31
|
1; |
54
|
|
|
|
|
|
|
|
55
|
12
|
|
|
|
|
22
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Rose::HTML::Form::Field::OptionGroup - Object representation of a group of options in a pop-up menu or select box in an HTML form. |
59
|
34
|
|
|
|
|
85
|
|
60
|
|
|
|
|
|
|
=head1 SYNOPSIS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$field = |
63
|
|
|
|
|
|
|
Rose::HTML::Form::Field::OptionGroup->new( |
64
|
|
|
|
|
|
|
name => 'fruits', |
65
|
|
|
|
|
|
|
label => 'Fruits'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$field->options(apple => 'Apple', |
68
|
|
|
|
|
|
|
orange => 'Orange', |
69
|
|
|
|
|
|
|
grape => 'Grape'); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
print $field->html; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
... |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
L<Rose::HTML::Form::Field::OptionGroup> is an object representation of a group of options in a pop-up menu or select box in an HTML form. Yes, this is the often-overlooked (and sometimes ill-supported) "optgroup" HTML tag. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
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. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 HTML ATTRIBUTES |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Valid attributes: |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
accesskey |
86
|
|
|
|
|
|
|
class |
87
|
|
|
|
|
|
|
dir |
88
|
|
|
|
|
|
|
disabled |
89
|
|
|
|
|
|
|
id |
90
|
|
|
|
|
|
|
label |
91
|
|
|
|
|
|
|
lang |
92
|
|
|
|
|
|
|
name |
93
|
|
|
|
|
|
|
onblur |
94
|
|
|
|
|
|
|
onclick |
95
|
|
|
|
|
|
|
ondblclick |
96
|
|
|
|
|
|
|
onfocus |
97
|
|
|
|
|
|
|
onkeydown |
98
|
|
|
|
|
|
|
onkeypress |
99
|
|
|
|
|
|
|
onkeyup |
100
|
|
|
|
|
|
|
onmousedown |
101
|
|
|
|
|
|
|
onmousemove |
102
|
|
|
|
|
|
|
onmouseout |
103
|
|
|
|
|
|
|
onmouseover |
104
|
|
|
|
|
|
|
onmouseup |
105
|
|
|
|
|
|
|
style |
106
|
|
|
|
|
|
|
tabindex |
107
|
|
|
|
|
|
|
title |
108
|
|
|
|
|
|
|
value |
109
|
|
|
|
|
|
|
xml:lang |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Required attributes: |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
label |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Boolean attributes: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
disabled |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=over 4 |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item B<new PARAMS> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Constructs a new L<Rose::HTML::Form::Field::OptionGroup> object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item B<add_option OPTION> |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Convenience alias for L<add_options()|/add_options>. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item B<add_options OPTIONS> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Adds options to the option group. OPTIONS may be a reference to a hash of value/label pairs, a reference to an array of values, or a list of L<Rose::HTML::Form::Field::Option> objects. Passing an odd number of items in the value/label argument list causes a fatal error. Options passed as a hash reference are sorted by the keys of the hash according to the default behavior of Perl's built-in L<sort()|perlfunc/sort> function. Options are added to the end of the existing list of options. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item B<choices [OPTIONS]> |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This is an alias for the L<options|/options> method. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item B<has_value VALUE> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns true if VALUE is selected in the option group, false otherwise. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item B<label [VALUE]> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Get or set the value of the "label" HTML attribute. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item B<labels [LABELS]> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Get or set the labels for all values. If LABELS is a reference to a hash or a list of value/label pairs, then LABELS replaces all existing labels. Passing an odd number of items in the list version of LABELS causes a fatal error. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Returns a hash of value/label pairs in list context, or a reference to a hash in scalar context. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item B<option VALUE> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Returns the first option (according to the order that they are returned from L<options()|/options>) whose "value" HTML attribute is VALUE, or undef if no such option exists. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item B<options OPTIONS> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Get or set the full list of options in the pop-up menu. OPTIONS may be a reference to a hash of value/label pairs, a reference to an array of values, or a list of L<Rose::HTML::Form::Field::Option> objects. Passing an odd number of items in the value/label argument list causes a fatal error. Options passed as a hash reference are sorted by the keys of the hash according to the default behavior of Perl's built-in L<sort()|perlfunc/sort> function. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
To set an ordered list of option values along with labels in the constructor, use both the L<options()|/options> and L<labels()|/labels> methods in the correct order. Example: |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$field = |
170
|
|
|
|
|
|
|
Rose::HTML::Form::Field::OptionGroup->new( |
171
|
|
|
|
|
|
|
name => 'fruits', |
172
|
|
|
|
|
|
|
options => [ 'apple', 'pear' ], |
173
|
|
|
|
|
|
|
labels => { apple => 'Apple', pear => 'Pear' }); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Remember that methods are called in the order that they appear in the constructor arguments (see the L<Rose::Object> documentation), so L<options()|/options> will be called before L<labels()|/labels> in the example above. This is important; it will not work in the opposite order. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns a list of the pop-up menu's L<Rose::HTML::Form::Field::Option> objects in list context, or a reference to an array of the same in scalar context. These are the actual objects used in the field. Modifying them will modify the field itself. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item B<value_label> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Returns the label of the first selected value (according to the order that they are returned by L<internal_value()|Rose::HTML::Form::Field/internal_value>), or the value itself if it has no label. If no value is selected, undef is returned. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 AUTHOR |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 LICENSE |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
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. |