| 1 |
package HTML::FormHandler::Field::Result; |
| 2 |
# ABSTRACT: result class for fields |
| 3 |
$HTML::FormHandler::Field::Result::VERSION = '0.410002'; |
| 4 |
use Moose; |
| 5 |
with 'HTML::FormHandler::Result::Role'; |
| 6 |
|
| 7 |
|
| 8 |
has 'value' => ( |
| 9 |
is => 'ro', |
| 10 |
writer => '_set_value', |
| 11 |
clearer => '_clear_value', |
| 12 |
predicate => 'has_value', |
| 13 |
); |
| 14 |
|
| 15 |
has 'field_def' => ( |
| 16 |
is => 'ro', |
| 17 |
isa => 'HTML::FormHandler::Field', |
| 18 |
writer => '_set_field_def', |
| 19 |
); |
| 20 |
|
| 21 |
has 'missing' => ( is => 'rw', isa => 'Bool' ); |
| 22 |
|
| 23 |
sub fif { |
| 24 |
my $self = shift; |
| 25 |
return $self->field_def->fif($self); |
| 26 |
} |
| 27 |
|
| 28 |
sub fields_fif { |
| 29 |
my ( $self, $prefix ) = @_; |
| 30 |
return $self->field_def->fields_fif( $self, $prefix ); |
| 31 |
} |
| 32 |
|
| 33 |
sub render { |
| 34 |
my $self = shift; |
| 35 |
return $self->field_def->render($self); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
sub peek { |
| 40 |
my ( $self, $indent ) = @_; |
| 41 |
$indent ||= ''; |
| 42 |
my $name = $self->field_def ? $self->field_def->full_name : $self->name; |
| 43 |
my $type = $self->field_def ? $self->field_def->type : 'unknown'; |
| 44 |
my $string = $indent . "result " . $name . " type: " . $type . "\n"; |
| 45 |
$string .= $indent . "....value => " . $self->value . "\n" if $self->has_value; |
| 46 |
if( $self->has_results ) { |
| 47 |
$indent .= ' '; |
| 48 |
foreach my $res ( $self->results ) { |
| 49 |
$string .= $res->peek( $indent ); |
| 50 |
} |
| 51 |
} |
| 52 |
return $string; |
| 53 |
} |
| 54 |
|
| 55 |
__PACKAGE__->meta->make_immutable; |
| 56 |
use namespace::autoclean; |
| 57 |
1; |
| 58 |
|
| 59 |
__END__ |
| 60 |
|
| 61 |
=pod |
| 62 |
|
| 63 |
=encoding UTF-8 |
| 64 |
|
| 65 |
=head1 NAME |
| 66 |
|
| 67 |
HTML::FormHandler::Field::Result - result class for fields |
| 68 |
|
| 69 |
=head1 VERSION |
| 70 |
|
| 71 |
version 0.410002 |
| 72 |
|
| 73 |
=head1 SYNOPSIS |
| 74 |
|
| 75 |
Result class for L<HTML::FormHandler::Field> |
| 76 |
|
| 77 |
=head1 AUTHOR |
| 78 |
|
| 79 |
FormHandler Contributors - see HTML::FormHandler |
| 80 |
|
| 81 |
=head1 COPYRIGHT AND LICENSE |
| 82 |
|
| 83 |
This software is copyright (c) 2017 by Gerda Shank. |
| 84 |
|
| 85 |
This is free software; you can redistribute it and/or modify it under |
| 86 |
the same terms as the Perl 5 programming language system itself. |
| 87 |
|
| 88 |
=cut |