PageRenderTime 27ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/lib/HTML/FormHandler/Widget/Field/Upload.pm

http://github.com/gshank/html-formhandler
Perl | 35 lines | 26 code | 8 blank | 1 comment | 1 complexity | bb559978c22886de67086fe5d7bdad97 MD5 | raw file
 1package HTML::FormHandler::Widget::Field::Upload;
 2# ABSTRACT: update field rendering widget
 3
 4use Moose::Role;
 5use HTML::FormHandler::Render::Util ('process_attrs');
 6
 7=head1 SYNOPSIS
 8
 9Renders an Upload field
10
11=cut
12
13sub render_element {
14    my ( $self, $result ) = @_;
15
16    $result ||= $self->result;
17    my $output;
18    $output = '<input type="file" name="';
19    $output .= $self->html_name . '"';
20    $output .= ' id="' . $self->id . '"';
21    $output .= process_attrs($self->element_attributes($result));
22    $output .= ' />';
23    return $output;
24}
25
26sub render {
27    my ( $self, $result ) = @_;
28    $result ||= $self->result;
29    die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result;
30    my $output = $self->render_element( $result );
31    return $self->wrap_field( $result, $output );
32}
33
34use namespace::autoclean;
351;