PageRenderTime 29ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

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