| 1 | use warnings; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | package Jifty::Web::Form::Field::Upload; | ||
| 5 | |||
| 6 | =head1 NAME | ||
| 7 | |||
| 8 | Jifty::Web::Form::Field::Upload - File upload field | ||
| 9 | |||
| 10 | =head1 DESCRIPTION | ||
| 11 | |||
| 12 | An input field that renders using C<< <input type="file" /> >>. The | ||
| 13 | argument value that the action receives from this field via | ||
| 14 | L<Jifty::Action/argument_value> will be a filehandle, which can be | ||
| 15 | read in the usual ways. | ||
| 16 | |||
| 17 | =cut | ||
| 18 | |||
| 19 | use base qw/Jifty::Web::Form::Field/; | ||
| 20 | |||
| 21 | =head2 render_widget | ||
| 22 | |||
| 23 | Renders the file upload widget. | ||
| 24 | |||
| 25 | =cut | ||
| 26 | |||
| 27 | sub render_widget { | ||
| 28 | my $self = shift; | ||
| 29 | my $field = qq!<input type="file" name="@{[ $self->input_name ]}" !; | ||
| 30 | $field .= $self->_widget_class(); | ||
| 31 | $field .= $self->javascript; | ||
| 32 | $field .= qq!/>!; | ||
| 33 | Jifty->web->out($field); | ||
| 34 | ''; | ||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | =head2 render_value | ||
| 39 | |||
| 40 | The 'value', rendered, is empty so that BLOBs and the like don't get | ||
| 41 | streamed to the browser. | ||
| 42 | |||
| 43 | =cut | ||
| 44 | |||
| 45 | sub render_value { | ||
| 46 | ''; | ||
| 47 | } | ||
| 48 | |||
| 49 | =head2 classes | ||
| 50 | |||
| 51 | Add 'upload' to the rest of the classes | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | sub classes { | ||
| 56 | my $self = shift; | ||
| 57 | return join(' ', 'upload', ($self->SUPER::classes)); | ||
| 58 | } | ||
| 59 | |||
| 60 | 1; |