a1d181cfa724bc15710a5357a556a64547c7ddea
[catagits/Reaction.git] / lib / Reaction / UI / ViewPort / Field / File.pm
1 package Reaction::UI::ViewPort::Field::File;
2
3 use Reaction::Class;
4 use Reaction::Types::File;
5
6 class File is 'Reaction::UI::ViewPort::Field', which {
7
8   has '+value' => (isa => 'File', required => 0);
9
10   #has '+layout' => (default => 'file');
11
12   override apply_our_events => sub {
13     my ($self, $ctx, $events) = @_;
14     my $value_key = join(':', $self->location, 'value');
15     if (my $upload = $ctx->req->upload($value_key)) {
16       local $events->{$value_key} = $upload;
17       return super();
18     } else {
19       return super();
20     }
21   };
22
23 };
24
25 1;
26
27 =head1 NAME
28
29 Reaction::UI::ViewPort::Field::File
30
31 =head1 DESCRIPTION
32
33 =head1 SEE ALSO
34
35 =head2 L<Reaction::UI::ViewPort::Field>
36
37 =head1 AUTHORS
38
39 See L<Reaction::Class> for authors.
40
41 =head1 LICENSE
42
43 See L<Reaction::Class> for the license.
44
45 =cut