line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::HTML::Form::Field::Submit; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
105563
|
use strict; |
|
5
|
|
|
|
|
28
|
|
|
5
|
|
|
|
|
195
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
35
|
use Carp(); |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
131
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
32
|
use base 'Rose::HTML::Form::Field::Input'; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
1395
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Rose::Object::MakeMethods::Generic |
10
|
|
|
|
|
|
|
( |
11
|
5
|
|
|
|
|
68
|
'boolean' => 'was_submitted', |
12
|
5
|
|
|
5
|
|
45
|
); |
|
5
|
|
|
|
|
28
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Rose::HTML::Object::MakeMethods::Localization |
15
|
|
|
|
|
|
|
( |
16
|
5
|
|
|
|
|
84
|
localized_message => |
17
|
|
|
|
|
|
|
[ |
18
|
|
|
|
|
|
|
qw(_value) |
19
|
|
|
|
|
|
|
], |
20
|
5
|
|
|
5
|
|
843
|
); |
|
5
|
|
|
|
|
14
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
__PACKAGE__->add_required_html_attrs( |
23
|
|
|
|
|
|
|
{ |
24
|
|
|
|
|
|
|
type => 'submit', |
25
|
|
|
|
|
|
|
name => '', |
26
|
|
|
|
|
|
|
}); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.616'; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
0
|
0
|
sub is_button { 1 } |
31
|
30
|
|
|
30
|
1
|
70
|
sub is_empty { 1 } |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
0
|
1
|
0
|
sub hidden_fields { (wantarray) ? () : [] } |
34
|
0
|
0
|
|
0
|
1
|
0
|
sub html_hidden_fields { (wantarray) ? () : [] } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
*xhtml_hidden_fields = \&html_hidden_fields; |
37
|
|
|
|
|
|
|
|
38
|
107
|
|
|
107
|
1
|
241
|
sub clear { shift->was_submitted(0) } |
39
|
1
|
|
|
1
|
1
|
4
|
sub reset { shift->was_submitted(0) } |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
1
|
7
|
sub image_html { shift->__image_html(0, @_) } |
42
|
1
|
|
|
1
|
1
|
6
|
sub image_xhtml { shift->__image_html(1, @_) } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub __image_html |
45
|
|
|
|
|
|
|
{ |
46
|
2
|
|
|
2
|
|
7
|
my($self, $xhtml, %args) = @_; |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
6
|
$args{'type'} = 'image'; |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
4
|
my %old; |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
10
|
while(my($k, $v) = each(%args)) |
53
|
|
|
|
|
|
|
{ |
54
|
6
|
50
|
|
|
|
21
|
if($self->html_attr_exists($k)) |
55
|
|
|
|
|
|
|
{ |
56
|
6
|
|
|
|
|
16
|
$old{$k} = $self->html_attr($k); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
6
|
|
|
|
|
14
|
$self->html_attr($k => $v); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
2
|
50
|
|
|
|
5
|
Carp::croak("Missing src attribute") unless(length $self->html_attr('src')); |
63
|
|
|
|
|
|
|
|
64
|
2
|
100
|
|
|
|
16
|
my $ret = $xhtml ? $self->xhtml : $self->html; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Back out changes |
67
|
2
|
|
|
|
|
8
|
foreach my $attr (keys %args) |
68
|
|
|
|
|
|
|
{ |
69
|
6
|
50
|
|
|
|
14
|
if(exists $old{$attr}) |
70
|
|
|
|
|
|
|
{ |
71
|
6
|
|
|
|
|
14
|
$self->html_attr($attr => $old{$attr}); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else |
74
|
|
|
|
|
|
|
{ |
75
|
0
|
|
|
|
|
0
|
$self->delete_html_attr($attr); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
2
|
|
|
|
|
17
|
return $ret; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub value_message_id |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
0
|
0
|
0
|
my($self) = shift; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
0
|
if(@_) |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
|
|
0
|
$self->_value_message_id(@_); |
89
|
0
|
|
|
|
|
0
|
return $self->html_attr(value => $self->_value); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
return $self->_value_message_id; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
*value_id = \&value_message_id; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub value |
98
|
|
|
|
|
|
|
{ |
99
|
40
|
|
|
40
|
1
|
204
|
my($self) = shift; |
100
|
|
|
|
|
|
|
|
101
|
40
|
100
|
|
|
|
118
|
if(@_) |
102
|
|
|
|
|
|
|
{ |
103
|
17
|
|
|
|
|
83
|
my $value = $self->_value(@_); |
104
|
17
|
|
|
|
|
176
|
return $self->SUPER::value($value); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
23
|
|
|
|
|
62
|
my $value = $self->html_attr('value'); |
108
|
|
|
|
|
|
|
|
109
|
23
|
50
|
|
|
|
89
|
unless(defined $value) |
110
|
|
|
|
|
|
|
{ |
111
|
0
|
|
|
|
|
0
|
return $self->html_attr(value => $self->_value); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
23
|
|
|
|
|
147
|
return $value; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub input_value |
118
|
|
|
|
|
|
|
{ |
119
|
22
|
|
|
22
|
1
|
54
|
my ($self, $value) = @_; |
120
|
5
|
|
|
5
|
|
3395
|
no warnings 'uninitialized'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
692
|
|
121
|
22
|
|
|
|
|
68
|
$self->was_submitted($value eq $self->value); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub internal_value |
125
|
|
|
|
|
|
|
{ |
126
|
27
|
|
|
27
|
1
|
48
|
my ($self) = shift; |
127
|
27
|
100
|
|
|
|
67
|
return $self->value if($self->was_submitted); |
128
|
26
|
|
|
|
|
173
|
return undef; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 NAME |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Submit - Object representation of a submit button in an HTML form. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SYNOPSIS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
$field = |
142
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Submit->new(name => 'run', |
143
|
|
|
|
|
|
|
value => 'Do it!'); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
print $field->html; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# or... |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
print $field->image_html(src => 'images/run_button.gif'); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
... |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 DESCRIPTION |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<Rose::HTML::Form::Field::Submit> is an object representation of a submit button in an HTML form. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
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. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 HTML ATTRIBUTES |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Valid attributes: |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
accept |
164
|
|
|
|
|
|
|
accesskey |
165
|
|
|
|
|
|
|
alt |
166
|
|
|
|
|
|
|
checked |
167
|
|
|
|
|
|
|
class |
168
|
|
|
|
|
|
|
dir |
169
|
|
|
|
|
|
|
disabled |
170
|
|
|
|
|
|
|
id |
171
|
|
|
|
|
|
|
ismap |
172
|
|
|
|
|
|
|
lang |
173
|
|
|
|
|
|
|
maxlength |
174
|
|
|
|
|
|
|
name |
175
|
|
|
|
|
|
|
onblur |
176
|
|
|
|
|
|
|
onchange |
177
|
|
|
|
|
|
|
onclick |
178
|
|
|
|
|
|
|
ondblclick |
179
|
|
|
|
|
|
|
onfocus |
180
|
|
|
|
|
|
|
onkeydown |
181
|
|
|
|
|
|
|
onkeypress |
182
|
|
|
|
|
|
|
onkeyup |
183
|
|
|
|
|
|
|
onmousedown |
184
|
|
|
|
|
|
|
onmousemove |
185
|
|
|
|
|
|
|
onmouseout |
186
|
|
|
|
|
|
|
onmouseover |
187
|
|
|
|
|
|
|
onmouseup |
188
|
|
|
|
|
|
|
onselect |
189
|
|
|
|
|
|
|
readonly |
190
|
|
|
|
|
|
|
size |
191
|
|
|
|
|
|
|
src |
192
|
|
|
|
|
|
|
style |
193
|
|
|
|
|
|
|
tabindex |
194
|
|
|
|
|
|
|
title |
195
|
|
|
|
|
|
|
type |
196
|
|
|
|
|
|
|
usemap |
197
|
|
|
|
|
|
|
value |
198
|
|
|
|
|
|
|
xml:lang |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Required attributes (default values in parentheses): |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
name |
203
|
|
|
|
|
|
|
type (submit) |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Boolean attributes: |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
checked |
208
|
|
|
|
|
|
|
disabled |
209
|
|
|
|
|
|
|
ismap |
210
|
|
|
|
|
|
|
readonly |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over 4 |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item B<new PARAMS> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Constructs a new L<Rose::HTML::Form::Field::Submit> object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=back |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over 4 |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item B<image_html [ARGS]> |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Returns the HTML serialization of the submit button using an image instead of a standard button widget (in other words, type="image"). ARGS is a list of HTML attribute name/value pairs which are temporarily set, then backed out before the method returns. (The type="image" change is also backed out.) |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
The "src" HTML attribute must be set (either in ARGS or from an existing value for that attribute) or a fatal error will occur. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item B<image_xhtml [ARGS]> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Like L<image_html()|/image_html>, but serialized to XHTML instead. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item B<is_empty> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Returns true. |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item B<value [VALUE]> |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Gets or sets the value of the "value" HTML attribute. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item B<was_submitted> |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Returns true if this submit button was pressed, false otherwise. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=back |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 AUTHOR |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 LICENSE |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
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. |