aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Reaction/UI/ViewPort/Field/Mutable/File.pm
blob: 5c1b35dd918540e9b65a0856c17006c57471bf68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package Reaction::UI::ViewPort::Field::Mutable::File;

use Reaction::Types::File qw/Upload/;
use Reaction::Class;

use namespace::clean -except => [ qw(meta) ];
extends 'Reaction::UI::ViewPort::Field';

with 'Reaction::UI::ViewPort::Field::Role::Mutable::Simple'
    => { value_type => Upload };

override apply_our_events => sub {
  my ($self, $events) = @_;
  my $value_key = $self->event_id_for('value_string');
  if (my $upload = $self->ctx->req->upload($value_key)) {
    local $events->{$value_key} = $upload;
    return super();
  } else {
    return super();
  }
};
sub adopt_value_string {
    my($self) = @_;
    $self->value($self->value_string) if $self->value_string;
};
override _value_string_from_value => sub { '' };

__PACKAGE__->meta->make_immutable;


1;