PageRenderTime 17ms CodeModel.GetById 2ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/HTML/FormHandler/Field/NoValue.pm

http://github.com/gshank/html-formhandler
Perl | 63 lines | 47 code | 14 blank | 2 comment | 4 complexity | b13247b5faedb3d0295ff5625723f4d0 MD5 | raw file
 1package HTML::FormHandler::Field::NoValue;
 2# ABSTRACT: base class for submit field
 3
 4use Moose;
 5extends 'HTML::FormHandler::Field';
 6
 7=head1 SYNOPSIS
 8
 9This is the base class for the Submit & Reset fields. It can be used for fields that
10do not produce valid 'values'. It should not be used for fields that
11produce a value or need validating.
12
13=cut
14
15has 'html' => ( is => 'rw', isa => 'Str', default => '' );
16has 'value' => (
17    is        => 'rw',
18    predicate => 'has_value',
19    clearer   => 'clear_value',
20);
21
22sub _result_from_fields {
23    my ( $self, $result ) = @_;
24    my $value = $self->get_default_value;
25    if ( $value ) {
26        $self->value($value);
27    }
28    $self->_set_result($result);
29    $result->_set_field_def($self);
30    return $result;
31}
32
33sub _result_from_input {
34    my ( $self, $result, $input, $exists ) = @_;
35    $self->_set_result($result);
36    $result->_set_field_def($self);
37    return $result;
38}
39
40sub _result_from_object {
41    my ( $self, $result, $value ) = @_;
42    $self->_set_result($result);
43    $result->_set_field_def($self);
44    return $result;
45}
46
47sub fif { }
48
49has '+widget'    => ( default => '' );
50has '+noupdate'  => ( default => 1 );
51
52sub validate_field { }
53
54#sub clear_value { }
55
56sub render {
57    my $self = shift;
58    return $self->html;
59}
60
61__PACKAGE__->meta->make_immutable;
62use namespace::autoclean;
631;