File Coverage

blib/lib/SparkX/Form/Field/Text.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 17 17 100.0


line stmt bran cond sub pod time code
1             package SparkX::Form::Field::Text;
2             our $VERSION = '0.2102';
3              
4              
5             # ABSTRACT: A Text field for SparkX::Form
6              
7 2     2   1973 use Moose;
  2         2  
  2         12  
8 2     2   9677 use HTML::Tiny;
  2         3849  
  2         253  
9              
10             extends 'Spark::Form::Field';
11             with 'Spark::Form::Field::Role::Printable::HTML',
12             'Spark::Form::Field::Role::Printable::XHTML';
13              
14             has '+value' => (
15             isa => 'Str',
16             );
17              
18             sub to_html {
19 1     1 1 55 return shift->_render(HTML::Tiny->new(mode => 'html'));
20             }
21              
22             sub to_xhtml {
23 2     2 1 106 return shift->_render(HTML::Tiny->new(mode => 'xml'));
24             }
25              
26             sub _render {
27 3     3   98 my ($self, $html) = @_;
28              
29 3         83 return $html->input({type => 'text', value => $self->value, name => $self->name});
30             }
31              
32             __PACKAGE__->meta->make_immutable;
33              
34             1;
35              
36              
37              
38             =pod
39              
40             =head1 NAME
41              
42             SparkX::Form::Field::Text - A Text field for SparkX::Form
43              
44             =head1 VERSION
45              
46             version 0.2102
47              
48             =head1 METHODS
49              
50             =head2 to_html() => Str
51              
52             Renders the field to HTML
53              
54             =head2 to_xhtml() => Str
55              
56             Renders the field to XHTML
57              
58             =head2 validate() => Bool
59              
60             Validates the field. Before composition with validators, always returns 1.
61              
62             =head1 SEE ALSO
63              
64             =over 4
65              
66             =item L<SparkX::Form> - The forms module this is to be used with
67              
68             =item L<SparkX::Form::BasicFields> - A collection of fields for use with C<Spark::Form>
69              
70             =back
71              
72              
73              
74             =head1 AUTHOR
75              
76             James Laver L<http://jameslaver.com>
77              
78             =head1 COPYRIGHT AND LICENSE
79              
80             This software is copyright (c) 2009 by James Laver C<< <sprintf qw(%s@%s.%s cpan jameslaver com)> >>.
81              
82             This is free software; you can redistribute it and/or modify it under
83             the same terms as the Perl 5 programming language system itself.
84              
85             =cut
86              
87              
88              
89             __END__
90