Widget/Element/Textfield.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 37 CC 3 SCAR 19.5
CC
3
Cov
0%
containerize
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 7.0
1 package HTML::Widget::Element::Textfield;
2  
3 use warnings;
4 use strict;
5 use base 'HTML::Widget::Element';
6  
7 __PACKAGE__->mk_accessors(qw/comment label value retain_default/);
8 __PACKAGE__->mk_attr_accessors(qw/size maxlength/);
9  
10 =head1 NAME
11  
12 HTML::Widget::Element::Textfield - Textfield Element
13  
14 =head1 SYNOPSIS
15  
16 my $e = $widget->element( 'Textfield', 'foo' );
17 $e->comment('(Required)');
18 $e->label('Foo');
19 $e->size(23);
20 $e->maxlength(42);
21 $e->value('bar');
22  
23 =head1 DESCRIPTION
24  
25 Textfield Element.
26  
27 =head1 METHODS
28  
29 =head2 retain_default
30  
31 If true, overrides the default behaviour, so that after a field is missing
32 from the form submission, the xml output will contain the default value,
33 rather than be empty.
34  
35 =head2 containerize
36  
37 =cut
38  
39 sub containerize {
40 my ( $self, $w, $value, $errors, $args ) = @_;
41  
42 $value = $self->value
43 if ( not defined $value )
44 and $self->retain_default || not $args->{submitted};
45  
46 $value = ref $value eq 'ARRAY' ? shift @$value : $value;
47  
48 my $l = $self->mk_label( $w, $self->label, $self->comment, $errors );
49 my $i = $self->mk_input( $w, { type => 'text', value => $value }, $errors );
50 my $e = $self->mk_error( $w, $errors );
51  
52 return $self->container( { element => $i, error => $e, label => $l } );
53 }
54  
55 =head1 SEE ALSO
56  
57 L<HTML::Widget::Element>
58  
59 =head1 AUTHOR
60  
61 Sebastian Riedel, C<sri@oook.de>
62  
63 =head1 LICENSE
64  
65 This library is free software, you can redistribute it and/or modify it under
66 the same terms as Perl itself.
67  
68 =cut
69  
70 1;