Widget/Element/Textarea.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 62 CC 4 SCAR 22.2
CC
4
Cov
0%
containerize
20.0
new
2.0
BEGIN
2.0
CRAP 9.2
1 package HTML::Widget::Element::Textarea;
2  
3 use warnings;
4 use strict;
5 use base 'HTML::Widget::Element';
6 use HTML::Element;
7 use NEXT;
8  
9 __PACKAGE__->mk_accessors(qw/comment label value retain_default/);
10 __PACKAGE__->mk_attr_accessors(qw/cols rows wrap/);
11  
12 =head1 NAME
13  
14 HTML::Widget::Element::Textarea - Textarea Element
15  
16 =head1 SYNOPSIS
17  
18 my $e = $widget->element( 'Textarea', 'foo' );
19 $e->comment('(Required)');
20 $e->label('Foo');
21 $e->cols(30);
22 $e->rows(40);
23 $e->value('bar');
24 $e->wrap('wrap');
25  
26 =head1 DESCRIPTION
27  
28 Textarea Element.
29  
30 =head1 METHODS
31  
32 =head2 new
33  
34 Create new textarea with default size of 20 rows and 40 columns
35  
36 =cut
37  
38 sub new {
39 shift->NEXT::new(@_)->rows(20)->cols(40);
40 }
41  
42 =head2 containerize
43  
44 =cut
45  
46 sub containerize {
47 my ( $self, $w, $value, $errors, $args ) = @_;
48  
49 $value = $self->value
50 if ( not defined $value )
51 and $self->retain_default || not $args->{submitted};
52  
53 $value = ref $value eq 'ARRAY' ? shift @$value : $value;
54  
55 my $l = $self->mk_label( $w, $self->label, $self->comment, $errors );
56  
57 $self->attributes->{class} ||= 'textarea';
58 my $i = HTML::Element->new('textarea');
59 $i->push_content($value) if defined $value;
60 my $id = $self->id($w);
61 $i->attr( id => $id );
62 $i->attr( name => $self->name );
63  
64 $i->attr( $_ => ${ $self->attributes }{$_} )
65 for ( keys %{ $self->attributes } );
66  
67 my $e = $self->mk_error( $w, $errors );
68  
69 return $self->container( { element => $i, error => $e, label => $l } );
70 }
71  
72 =head2 label
73  
74 =head2 value
75  
76 =head2 cols
77  
78 =head2 rows
79  
80 =head2 wrap
81  
82 =head2 retain_default
83  
84 If true, overrides the default behaviour, so that after a field is missing
85 from the form submission, the xml output will contain the default value,
86 rather than be empty.
87  
88 =head1 SEE ALSO
89  
90 L<HTML::Widget::Element>
91  
92 =head1 AUTHOR
93  
94 Sebastian Riedel, C<sri@oook.de>
95  
96 =head1 LICENSE
97  
98 This library is free software, you can redistribute it and/or modify it under
99 the same terms as Perl itself.
100  
101 =cut
102  
103 1;