| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ark::Form; |
|
2
|
2
|
|
|
2
|
|
14
|
use utf8; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
10
|
|
|
3
|
2
|
|
|
2
|
|
61
|
use Mouse; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1570
|
use Clone 'clone'; |
|
|
2
|
|
|
|
|
5348
|
|
|
|
2
|
|
|
|
|
115
|
|
|
6
|
2
|
|
|
2
|
|
15
|
use Exporter::AutoClean; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
45
|
|
|
7
|
2
|
|
|
2
|
|
878
|
use HTML::Escape (); |
|
|
2
|
|
|
|
|
1216
|
|
|
|
2
|
|
|
|
|
51
|
|
|
8
|
2
|
|
|
2
|
|
944
|
use HTML::Shakan; |
|
|
2
|
|
|
|
|
330182
|
|
|
|
2
|
|
|
|
|
31
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends 'Class::Data::Inheritable'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_fields_data'); |
|
13
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_fields_data_order'); |
|
14
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_fields_messages'); |
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata('_widgets_class'); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has _shakan => ( |
|
18
|
|
|
|
|
|
|
is => 'rw', |
|
19
|
|
|
|
|
|
|
isa => 'HTML::Shakan', |
|
20
|
|
|
|
|
|
|
handles => [ |
|
21
|
|
|
|
|
|
|
qw/has_error load_function_message get_error_messages is_error is_valid |
|
22
|
|
|
|
|
|
|
set_error set_message/, # _shakan->_fvl |
|
23
|
|
|
|
|
|
|
qw/submitted submitted_and_valid fillin_param fillin_params |
|
24
|
|
|
|
|
|
|
param params upload uploads widgets/, # _shakan |
|
25
|
|
|
|
|
|
|
], |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'id_tmpl' => ( |
|
29
|
|
|
|
|
|
|
is => 'ro', |
|
30
|
|
|
|
|
|
|
isa => 'Str', |
|
31
|
|
|
|
|
|
|
default => 'id_%s', |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has context => ( |
|
35
|
|
|
|
|
|
|
is => 'rw', |
|
36
|
|
|
|
|
|
|
isa => 'Ark::Context', |
|
37
|
|
|
|
|
|
|
weak_ref => 1, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has request => ( |
|
41
|
|
|
|
|
|
|
is => 'rw', |
|
42
|
|
|
|
|
|
|
isa => 'Object', |
|
43
|
|
|
|
|
|
|
required => 1, |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has fields => ( |
|
47
|
|
|
|
|
|
|
is => 'ro', |
|
48
|
|
|
|
|
|
|
isa => 'HashRef', |
|
49
|
|
|
|
|
|
|
lazy => 1, |
|
50
|
|
|
|
|
|
|
default => sub { |
|
51
|
|
|
|
|
|
|
my $self = shift; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $fields = {}; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
for my $name (@{ $self->_fields_data_order }) { |
|
56
|
|
|
|
|
|
|
my %params = %{ clone $self->_fields_data->{ $name } }; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $field; |
|
59
|
|
|
|
|
|
|
my $type = delete $params{type} |
|
60
|
|
|
|
|
|
|
or die 'type parameter is required'; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
if (my $cv = delete $params{custom_validation}) { |
|
63
|
|
|
|
|
|
|
$params{custom_validation} = sub { $cv->($self, @_) }; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
if (ref $params{choices} eq 'CODE') { |
|
67
|
|
|
|
|
|
|
$params{choices} = $params{choices}->(); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
if ($self->needs_localize) { |
|
71
|
|
|
|
|
|
|
if (my $label = delete $params{label}) { |
|
72
|
|
|
|
|
|
|
$params{label} = $self->localize($label); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
if (my $choices = delete $params{choices}) { |
|
76
|
|
|
|
|
|
|
$params{choices} = []; |
|
77
|
|
|
|
|
|
|
while (my ($v, $l) = splice @$choices, 0, 2) { |
|
78
|
|
|
|
|
|
|
push @{ $params{choices} }, $v, $self->localize($l); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
if (my ($func) = grep { $type eq $_ } @HTML::Shakan::Fields::EXPORT) { |
|
84
|
|
|
|
|
|
|
$field = $self->can($func)->(%params); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
else { |
|
87
|
|
|
|
|
|
|
$field = HTML::Shakan::Field::Input->new( |
|
88
|
|
|
|
|
|
|
type => $type, |
|
89
|
|
|
|
|
|
|
%params, |
|
90
|
|
|
|
|
|
|
); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$fields->{ $name } = $field; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
$fields; |
|
97
|
|
|
|
|
|
|
}, |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
|
|
100
|
2
|
|
|
2
|
|
1812
|
no Mouse; |
|
|
2
|
|
|
|
|
11
|
|
|
|
2
|
|
|
|
|
25
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub EXPORT { |
|
103
|
2
|
|
|
2
|
0
|
8
|
my ($class, $target) = @_; |
|
104
|
|
|
|
|
|
|
|
|
105
|
2
|
|
|
|
|
5
|
my %cloned; |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Exporter::AutoClean->export( |
|
108
|
|
|
|
|
|
|
$target, |
|
109
|
|
|
|
|
|
|
param => sub { |
|
110
|
|
|
|
|
|
|
# XXX: fix this, need more clean param declation inheritance |
|
111
|
4
|
100
|
|
4
|
|
656
|
unless ($cloned{$target}++) { |
|
112
|
2
|
|
|
|
|
6
|
for my $cd (qw/_fields_messages _fields_data _fields_data_order/) { |
|
113
|
6
|
|
|
|
|
200
|
Class::Data::Inheritable::mk_classdata( |
|
114
|
|
|
|
|
|
|
$target, $cd, clone $class->$cd, |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} |
|
118
|
4
|
|
|
|
|
69
|
$target->set_param_data(@_); |
|
119
|
|
|
|
|
|
|
}, |
|
120
|
|
|
|
|
|
|
widgets => sub { |
|
121
|
0
|
|
|
0
|
|
0
|
Mouse::load_class($_[0]); |
|
122
|
0
|
|
|
|
|
0
|
$target->_widgets_class($_[0]); |
|
123
|
|
|
|
|
|
|
}, |
|
124
|
2
|
|
|
|
|
57
|
); |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
{ |
|
127
|
2
|
|
|
2
|
|
645
|
no strict 'refs'; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
4246
|
|
|
|
2
|
|
|
|
|
198
|
|
|
128
|
2
|
|
|
|
|
9
|
*{"$target\::x"} = \&x; |
|
|
2
|
|
|
|
|
32
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub BUILDARGS { |
|
133
|
10
|
|
|
10
|
0
|
191
|
my ($self, $request, $context) = @_; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
return { |
|
136
|
10
|
50
|
|
|
|
167
|
request => $request, |
|
137
|
|
|
|
|
|
|
$context ? (context => $context) : (), |
|
138
|
|
|
|
|
|
|
}; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub BUILD { |
|
142
|
10
|
|
|
10
|
0
|
24
|
my $self = shift; |
|
143
|
10
|
|
|
|
|
29
|
$self->reset; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub reset { |
|
147
|
10
|
|
|
10
|
0
|
13
|
my $self = shift; |
|
148
|
|
|
|
|
|
|
|
|
149
|
10
|
|
|
|
|
7652
|
my $fields = $self->fields; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$self->_shakan( HTML::Shakan->new( |
|
152
|
|
|
|
|
|
|
request => $self->request, |
|
153
|
20
|
|
|
|
|
173
|
fields => [map { $fields->{$_} } @{ $self->_fields_data_order }], |
|
|
10
|
|
|
|
|
25
|
|
|
154
|
|
|
|
|
|
|
$self->can('custom_validation') |
|
155
|
10
|
50
|
|
10
|
|
37
|
? (custom_validation => sub { $self->custom_validation(@_) }) : (), |
|
|
10
|
50
|
|
|
|
12556
|
|
|
156
|
|
|
|
|
|
|
$self->_widgets_class |
|
157
|
|
|
|
|
|
|
? (widgets => $self->_widgets_class) : (), |
|
158
|
|
|
|
|
|
|
)); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub field { |
|
162
|
11
|
|
|
11
|
0
|
23
|
my ($class, $name, $value) = @_; |
|
163
|
|
|
|
|
|
|
|
|
164
|
11
|
50
|
|
|
|
25
|
if ($value) { |
|
165
|
0
|
|
|
|
|
0
|
$class->fields->{ $name } = $value; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
11
|
|
|
|
|
59
|
$class->fields->{ $name }; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub set_param_data { |
|
172
|
4
|
|
|
4
|
0
|
19
|
my ($self, $name, %params) = @_; |
|
173
|
|
|
|
|
|
|
|
|
174
|
4
|
|
|
|
|
11
|
my $overwrite = $name =~ s/^\+//; |
|
175
|
4
|
|
|
|
|
8
|
my $class = caller(1); |
|
176
|
|
|
|
|
|
|
|
|
177
|
4
|
|
|
|
|
11
|
$params{name} = $name; |
|
178
|
|
|
|
|
|
|
|
|
179
|
4
|
100
|
|
|
|
14
|
$class->_fields_messages({}) unless $class->_fields_messages; |
|
180
|
4
|
100
|
|
|
|
56
|
if (my $messages = delete $params{messages}) { |
|
181
|
2
|
50
|
|
|
|
13
|
for my $func (keys %{ $messages || {} }) { |
|
|
2
|
|
|
|
|
11
|
|
|
182
|
6
|
|
|
|
|
7874
|
my $message = $messages->{$func}; |
|
183
|
6
|
|
|
|
|
19
|
$class->_fields_messages->{ "$name.$func" } = $message; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
4
|
100
|
|
|
|
27
|
$class->_fields_data({}) unless $class->_fields_data; |
|
188
|
4
|
50
|
|
|
|
48
|
if ($overwrite) { |
|
189
|
0
|
0
|
|
|
|
0
|
my $data = $class->_fields_data->{ $name } |
|
190
|
|
|
|
|
|
|
or die qq{param "$name" does not defined by parent class}; |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
0
|
while (my ($k, $v) = each %params) { |
|
193
|
0
|
|
|
|
|
0
|
$data->{ $k } = $v; |
|
194
|
|
|
|
|
|
|
} |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
else { |
|
197
|
4
|
|
50
|
|
|
24
|
$params{attr} ||= {}; |
|
198
|
4
|
|
33
|
|
|
32
|
defined $params{$_} and $params{attr}{$_} ||= $params{$_} for qw/id name value/; |
|
|
|
|
100
|
|
|
|
|
|
199
|
|
|
|
|
|
|
|
|
200
|
4
|
|
|
|
|
13
|
$class->_fields_data->{ $name } = \%params; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
|
|
203
|
4
|
100
|
|
|
|
36
|
$class->_fields_data_order([]) unless $class->_fields_data_order; |
|
204
|
4
|
|
|
|
|
24
|
push @{ $class->_fields_data_order }, $name |
|
205
|
4
|
50
|
|
|
|
67
|
unless grep { $_ eq $name } @{ $class->_fields_data_order }; |
|
|
2
|
|
|
|
|
20
|
|
|
|
4
|
|
|
|
|
11
|
|
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
sub label { |
|
209
|
1
|
|
|
1
|
0
|
4
|
my ($self, $name) = @_; |
|
210
|
|
|
|
|
|
|
|
|
211
|
1
|
50
|
|
|
|
4
|
my $field = $self->field($name) or return; |
|
212
|
1
|
50
|
|
|
|
5
|
my $label = $field->label or return; |
|
213
|
|
|
|
|
|
|
|
|
214
|
1
|
50
|
|
|
|
16
|
unless ($field->id) { |
|
215
|
1
|
|
|
|
|
30
|
$field->id(sprintf($self->id_tmpl, $name)); |
|
216
|
|
|
|
|
|
|
} |
|
217
|
|
|
|
|
|
|
|
|
218
|
1
|
|
|
|
|
23
|
sprintf q{<label for="%s">%s</label>}, |
|
219
|
|
|
|
|
|
|
HTML::Escape::escape_html($field->id), HTML::Escape::escape_html($label); |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub input { |
|
223
|
3
|
|
|
3
|
0
|
10
|
my ($self, $name) = @_; |
|
224
|
|
|
|
|
|
|
|
|
225
|
3
|
50
|
|
|
|
11
|
my $field = $self->field($name) or return; |
|
226
|
3
|
|
|
|
|
29
|
$self->widgets->render( $self, $field ); |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub render { |
|
230
|
1
|
|
|
1
|
0
|
5
|
my ($self, $name) = @_; |
|
231
|
1
|
50
|
|
|
|
4
|
return $self->_shakan->render unless $name; |
|
232
|
|
|
|
|
|
|
|
|
233
|
1
|
|
50
|
|
|
16
|
my $res = ($self->label($name) || '') |
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
234
|
|
|
|
|
|
|
. ($self->input($name) || '') |
|
235
|
|
|
|
|
|
|
. ($self->error_message($name) || ''); |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub valid_param { |
|
239
|
0
|
|
|
0
|
0
|
0
|
my ($self, $name) = @_; |
|
240
|
0
|
0
|
|
|
|
0
|
return '' if $self->is_error($name); |
|
241
|
0
|
0
|
|
|
|
0
|
return defined($self->param($name)) ? $self->param($name) : ''; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub ignore_error { |
|
245
|
0
|
|
|
0
|
0
|
0
|
my ($self, $form, $name) = @_; |
|
246
|
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
0
|
delete $form->_fvl->{_error}{ $name }; |
|
248
|
0
|
|
|
|
|
0
|
@{ $form->_fvl->{_error_ary} } = |
|
249
|
0
|
|
|
|
|
0
|
grep { $_->[0] ne $name } @{ $form->_fvl->{_error_ary} }; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
250
|
|
|
|
|
|
|
} |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
sub needs_localize { |
|
253
|
27
|
|
|
27
|
0
|
39
|
my $self = shift; |
|
254
|
27
|
50
|
|
|
|
205
|
$self->context && $self->context->can('localize'); |
|
255
|
|
|
|
|
|
|
} |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub localize { |
|
258
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
259
|
0
|
0
|
|
|
|
0
|
return '' if $_[0] eq ''; |
|
260
|
0
|
0
|
|
|
|
0
|
$self->needs_localize && $self->context->localize(@_); |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub error_message_plain { |
|
264
|
5
|
|
|
5
|
0
|
430
|
my ($self, $name) = @_; |
|
265
|
5
|
50
|
|
|
|
20
|
return unless $self->is_error($name); |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
my ($error) = |
|
268
|
5
|
50
|
|
|
|
117
|
grep { $_->[0] eq $name } @{ $self->_shakan->_fvl->{_error_ary} || [] } |
|
|
10
|
50
|
|
|
|
53
|
|
|
|
5
|
|
|
|
|
35
|
|
|
269
|
|
|
|
|
|
|
or return; |
|
270
|
|
|
|
|
|
|
|
|
271
|
5
|
|
|
|
|
21
|
$self->_create_error_message($name, lc $error->[1]); |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub error_messages_plain { |
|
275
|
1
|
|
|
1
|
0
|
4
|
my ($self, $name) = @_; |
|
276
|
1
|
50
|
|
|
|
4
|
return unless $self->is_error($name); |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
my (@errors) = |
|
279
|
1
|
50
|
|
|
|
24
|
grep { $_->[0] eq $name } @{ $self->_shakan->_fvl->{_error_ary} || [] } |
|
|
3
|
50
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
7
|
|
|
280
|
|
|
|
|
|
|
or return; |
|
281
|
|
|
|
|
|
|
|
|
282
|
1
|
|
|
|
|
4
|
[map { $self->_create_error_message($name, lc $_->[1]) } @errors]; |
|
|
2
|
|
|
|
|
6
|
|
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub _create_error_message { |
|
286
|
7
|
|
|
7
|
|
16
|
my ($self, $name, $func) = @_; |
|
287
|
|
|
|
|
|
|
|
|
288
|
7
|
|
|
|
|
15
|
my $field = $self->field($name); |
|
289
|
7
|
100
|
33
|
|
|
37
|
my $label = $field ? $field->label || $field->name : $func; |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
my $messages = { |
|
292
|
7
|
50
|
|
|
|
23
|
%{ $self->messages || {} }, |
|
293
|
7
|
50
|
|
|
|
9
|
%{ $self->_fields_messages || {} }, |
|
|
7
|
|
|
|
|
257
|
|
|
294
|
|
|
|
|
|
|
}; |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
my $message = $messages->{"$name.$func"} |
|
297
|
7
|
|
66
|
|
|
128
|
|| $messages->{ $func }; |
|
298
|
|
|
|
|
|
|
|
|
299
|
7
|
50
|
|
|
|
16
|
unless ($message) { |
|
300
|
0
|
|
|
|
|
0
|
warn qq{Message "$name.$func" does not defined}; |
|
301
|
0
|
|
|
|
|
0
|
return; |
|
302
|
|
|
|
|
|
|
} |
|
303
|
|
|
|
|
|
|
|
|
304
|
7
|
50
|
|
|
|
27
|
if ($self->needs_localize) { |
|
305
|
0
|
|
|
|
|
0
|
$label = $self->localize( $label ); |
|
306
|
0
|
|
|
|
|
0
|
$message = $self->localize( $message, $label ); |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
else { |
|
309
|
|
|
|
|
|
|
my $gen_msg = sub { |
|
310
|
7
|
|
|
7
|
|
16
|
my ($tmpl, @args) = @_; |
|
311
|
7
|
|
|
|
|
12
|
local $_ = $tmpl; |
|
312
|
7
|
|
|
|
|
28
|
s!\[_(\d+)\]!$args[$1-1]!ge; |
|
|
2
|
|
|
|
|
14
|
|
|
313
|
7
|
|
|
|
|
32
|
$_; |
|
314
|
7
|
|
|
|
|
46
|
}; |
|
315
|
7
|
|
|
|
|
19
|
$message = $gen_msg->( $message, $label ); |
|
316
|
|
|
|
|
|
|
} |
|
317
|
|
|
|
|
|
|
|
|
318
|
7
|
|
|
|
|
78
|
$message; |
|
319
|
|
|
|
|
|
|
} |
|
320
|
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub error_message { |
|
322
|
3
|
|
|
3
|
0
|
1702
|
my ($self, $name) = @_; |
|
323
|
3
|
100
|
|
|
|
13
|
return unless $self->submitted; |
|
324
|
2
|
|
50
|
|
|
88
|
sprintf($self->message_format, $self->error_message_plain($name) || return); |
|
325
|
|
|
|
|
|
|
} |
|
326
|
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub error_messages { |
|
328
|
0
|
|
|
0
|
0
|
0
|
my ($self, $name) = @_; |
|
329
|
0
|
|
|
|
|
0
|
[ map { sprintf( $self->message_format, $_ ) } |
|
330
|
0
|
0
|
|
|
|
0
|
@{ $self->error_messages_plain($name) || [] } ]; |
|
|
0
|
|
|
|
|
0
|
|
|
331
|
|
|
|
|
|
|
} |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
sub fill { |
|
334
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
335
|
0
|
0
|
|
|
|
0
|
my $p = @_ > 1 ? {@_} : $_[0]; |
|
336
|
|
|
|
|
|
|
|
|
337
|
0
|
|
|
|
|
0
|
for my $k (keys %$p) { |
|
338
|
0
|
|
|
|
|
0
|
$self->fillin_params->{ $k } = $p->{ $k }; |
|
339
|
|
|
|
|
|
|
} |
|
340
|
|
|
|
|
|
|
} |
|
341
|
|
|
|
|
|
|
|
|
342
|
0
|
|
|
0
|
0
|
0
|
sub x { $_[0] }; |
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
sub messages { |
|
345
|
7
|
|
|
7
|
0
|
37
|
my $self = shift; |
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
return { |
|
348
|
|
|
|
|
|
|
not_null => '[_1] is required', |
|
349
|
105
|
|
|
|
|
144
|
map({ $_ => '[_1] is invalid' } qw/ |
|
350
|
|
|
|
|
|
|
int ascii date duplication length regex uint |
|
351
|
|
|
|
|
|
|
http_url |
|
352
|
|
|
|
|
|
|
email_loose |
|
353
|
|
|
|
|
|
|
hiragana jtel jzip katakana |
|
354
|
|
|
|
|
|
|
file_size file_mime |
|
355
|
|
|
|
|
|
|
/ ), |
|
356
|
7
|
|
|
|
|
18
|
%{ $self->_fields_messages }, |
|
|
7
|
|
|
|
|
18
|
|
|
357
|
|
|
|
|
|
|
}; |
|
358
|
|
|
|
|
|
|
} |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
sub message_format { |
|
361
|
2
|
|
|
2
|
0
|
10
|
'<span class="error">%s</span>'; |
|
362
|
|
|
|
|
|
|
} |
|
363
|
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
sub encode_entities { |
|
365
|
0
|
|
|
0
|
0
|
|
warn 'Ark::Form::encode_entities() is deprecated. use HTML::Escape::escape_html() instead'; |
|
366
|
0
|
|
|
|
|
|
HTML::Escape::escape_html(@_); |
|
367
|
|
|
|
|
|
|
} |
|
368
|
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |