Debian Codegraph @

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

raw
1 package HTML::FormHandler::Widget::Field::Text;
2 # ABSTRACT: text field rendering widget
3 $HTML::FormHandler::Widget::Field::Text::VERSION = '0.410002';
4 use Moose::Role;
5 use namespace::autoclean;
6 use HTML::FormHandler::Render::Util ('process_attrs');
7
8
9 sub render_element {
10 my $self = shift;
11 my $result = shift || $self->result;
12
13 my $t;
14 my $rendered = $self->html_filter($result->fif);
15 my $output = '<input type="' . $self->input_type . '" name="'
16 . $self->html_name . '" id="' . $self->id . '"';
17 $output .= qq{ size="$t"} if $t = $self->size;
18 $output .= qq{ maxlength="$t"} if $t = $self->maxlength;
19 $output .= ' value="' . $self->html_filter($result->fif) . '"';
20 $output .= process_attrs($self->element_attributes($result));
21 $output .= ' />';
22 return $output;
23 }
24
25 sub render {
26 my ( $self, $result ) = @_;
27 $result ||= $self->result;
28 die "No result for form field '" . $self->full_name . "'. Field may be inactive." unless $result;
29 my $output = $self->render_element( $result );
30 return $self->wrap_field( $result, $output );
31 }
32
33 1;
34
35 __END__
36
37 =pod
38
39 =encoding UTF-8
40
41 =head1 NAME
42
43 HTML::FormHandler::Widget::Field::Text - text field rendering widget
44
45 =head1 VERSION
46
47 version 0.410002
48
49 =head1 SYNOPSIS
50
51 Renders a text field
52
53 =head1 AUTHOR
54
55 FormHandler Contributors - see HTML::FormHandler
56
57 =head1 COPYRIGHT AND LICENSE
58
59 This software is copyright (c) 2017 by Gerda Shank.
60
61 This is free software; you can redistribute it and/or modify it under
62 the same terms as the Perl 5 programming language system itself.
63
64 =cut