line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Rose::HTML::Form::Field::Text; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
219934
|
use strict; |
|
17
|
|
|
|
|
123
|
|
|
17
|
|
|
|
|
569
|
|
4
|
|
|
|
|
|
|
|
5
|
17
|
|
|
17
|
|
9522
|
use Encode; |
|
17
|
|
|
|
|
171242
|
|
|
17
|
|
|
|
|
1457
|
|
6
|
17
|
|
|
17
|
|
2106
|
use Rose::HTML::Object::Errors qw(:string); |
|
17
|
|
|
|
|
46
|
|
|
17
|
|
|
|
|
138
|
|
7
|
|
|
|
|
|
|
|
8
|
17
|
|
|
17
|
|
120
|
use base 'Rose::HTML::Form::Field::Input'; |
|
17
|
|
|
|
|
40
|
|
|
17
|
|
|
|
|
8256
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.606'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->delete_valid_html_attrs(qw(ismap usemap alt src)); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->add_required_html_attrs( |
15
|
|
|
|
|
|
|
{ |
16
|
|
|
|
|
|
|
type => 'text', |
17
|
|
|
|
|
|
|
name => '', |
18
|
|
|
|
|
|
|
size => 15, |
19
|
|
|
|
|
|
|
value => '', |
20
|
|
|
|
|
|
|
}); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub html_field |
23
|
|
|
|
|
|
|
{ |
24
|
142
|
|
|
142
|
1
|
5484
|
my($self) = shift; |
25
|
142
|
|
|
|
|
510
|
$self->html_attr(value => $self->output_value); |
26
|
142
|
|
|
|
|
576
|
return $self->SUPER::html_field(@_); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub xhtml_field |
30
|
|
|
|
|
|
|
{ |
31
|
95
|
|
|
95
|
1
|
249
|
my($self) = shift; |
32
|
95
|
|
|
|
|
329
|
$self->html_attr(value => $self->output_value); |
33
|
95
|
|
|
|
|
402
|
return $self->SUPER::xhtml_field(@_); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub validate |
37
|
|
|
|
|
|
|
{ |
38
|
134
|
|
|
134
|
1
|
324
|
my($self) = shift; |
39
|
|
|
|
|
|
|
|
40
|
134
|
|
|
|
|
461
|
my $ok = $self->SUPER::validate(@_); |
41
|
134
|
100
|
|
|
|
364
|
return $ok unless($ok); |
42
|
|
|
|
|
|
|
|
43
|
123
|
|
|
|
|
298
|
my $value = $self->input_value; |
44
|
123
|
50
|
|
|
|
344
|
$value = $self->output_value if(ref $value); |
45
|
123
|
100
|
100
|
|
|
532
|
return 1 unless(defined $value && length $value); |
46
|
|
|
|
|
|
|
|
47
|
97
|
|
|
|
|
357
|
my $maxlength = $self->maxlength; |
48
|
|
|
|
|
|
|
|
49
|
97
|
0
|
|
0
|
|
555
|
my $name = sub { $self->error_label || $self->name }; |
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
|
51
|
97
|
100
|
66
|
|
|
486
|
if(ref($self)->force_utf8 && !Encode::is_utf8($value)) |
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
|
|
29
|
Encode::_utf8_on($value); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
97
|
100
|
100
|
|
|
6692
|
if(defined $maxlength && length($value) > $maxlength) |
57
|
|
|
|
|
|
|
{ |
58
|
3
|
|
|
|
|
23
|
$self->add_error_id(STRING_OVERFLOW, { label => $name, maxlength => $maxlength }); |
59
|
3
|
|
|
|
|
18
|
return 0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
94
|
|
|
|
|
533
|
return 1; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
if(__PACKAGE__->localizer->auto_load_messages) |
66
|
|
|
|
|
|
|
{ |
67
|
|
|
|
|
|
|
__PACKAGE__->localizer->load_all_messages; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
17
|
|
|
17
|
|
317
|
use utf8; # The __DATA__ section contains UTF-8 text |
|
17
|
|
|
|
|
58
|
|
|
17
|
|
|
|
|
117
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__DATA__ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
[% LOCALE en %] |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
STRING_OVERFLOW = "[label] must not exceed [maxlength] characters." |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
[% LOCALE bg %] |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
STRING_OVERFLOW = "Полето '[label]' не трябва да надхвърля [maxlength] символа." |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__END__ |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Text - Object representation of a text field in an HTML form. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$field = |
93
|
|
|
|
|
|
|
Rose::HTML::Form::Field::Text->new( |
94
|
|
|
|
|
|
|
label => 'Your Age', |
95
|
|
|
|
|
|
|
name => 'age', |
96
|
|
|
|
|
|
|
size => 2, |
97
|
|
|
|
|
|
|
maxlength => 3); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
$age = $field->internal_value; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
print $field->html; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
... |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DESCRIPTION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<Rose::HTML::Form::Field::Text> is an object representation of a text field in an HTML form. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
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. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 HTML ATTRIBUTES |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Valid attributes: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
accept |
116
|
|
|
|
|
|
|
accesskey |
117
|
|
|
|
|
|
|
checked |
118
|
|
|
|
|
|
|
class |
119
|
|
|
|
|
|
|
dir |
120
|
|
|
|
|
|
|
disabled |
121
|
|
|
|
|
|
|
id |
122
|
|
|
|
|
|
|
lang |
123
|
|
|
|
|
|
|
maxlength |
124
|
|
|
|
|
|
|
name |
125
|
|
|
|
|
|
|
onblur |
126
|
|
|
|
|
|
|
onchange |
127
|
|
|
|
|
|
|
onclick |
128
|
|
|
|
|
|
|
ondblclick |
129
|
|
|
|
|
|
|
onfocus |
130
|
|
|
|
|
|
|
onkeydown |
131
|
|
|
|
|
|
|
onkeypress |
132
|
|
|
|
|
|
|
onkeyup |
133
|
|
|
|
|
|
|
onmousedown |
134
|
|
|
|
|
|
|
onmousemove |
135
|
|
|
|
|
|
|
onmouseout |
136
|
|
|
|
|
|
|
onmouseover |
137
|
|
|
|
|
|
|
onmouseup |
138
|
|
|
|
|
|
|
onselect |
139
|
|
|
|
|
|
|
readonly |
140
|
|
|
|
|
|
|
size |
141
|
|
|
|
|
|
|
style |
142
|
|
|
|
|
|
|
tabindex |
143
|
|
|
|
|
|
|
title |
144
|
|
|
|
|
|
|
type |
145
|
|
|
|
|
|
|
value |
146
|
|
|
|
|
|
|
xml:lang |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Required attributes (default values in parentheses): |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
name |
151
|
|
|
|
|
|
|
size (15) |
152
|
|
|
|
|
|
|
type (text) |
153
|
|
|
|
|
|
|
value |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Boolean attributes: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
checked |
158
|
|
|
|
|
|
|
disabled |
159
|
|
|
|
|
|
|
readonly |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=over 4 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item B<new PARAMS> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Constructs a new L<Rose::HTML::Form::Field::Text> object based on PARAMS, where PARAMS are name/value pairs. Any object method is a valid parameter name. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=back |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
John C. Siracusa (siracusa@gmail.com) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 LICENSE |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
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. |