Debian Codegraph @

Embperl/Form/Control/textarea.pm

raw
1
2 ###################################################################################
3 #
4 # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
5 # Embperl - Copyright (c) 2008-2014 Gerald Richter
6 #
7 # You may distribute under the terms of either the GNU General Public
8 # License or the Artistic License, as specified in the Perl README file.
9 #
10 # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
11 # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 #
14 # $Id$
15 #
16 ###################################################################################
17
18 package Embperl::Form::Control::textarea ;
19
20 use strict ;
21 use base 'Embperl::Form::Control' ;
22
23 use Embperl::Inline ;
24
25
26
27 1 ;
28
29 __EMBPERL__
30
31 [# ---------------------------------------------------------------------------
32 #
33 # show - output the control
34 #]
35
36 [$ sub show ($self, $req)
37
38 $]
39
40 [$if !$self -> {fullwidth} $]
41 [- $self -> SUPER::show ($req) -]
42 [$else$]
43
44 <table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]" style="width: 348px">
45 <tr>
46 <td class="ef-label-box ef-label-box-width-full [$ if $self->{labelclass} $][+ " $self->{labelclass}" +][$ endif $]">
47 [-
48 $fdat{$name} = $self -> {default} if ($fdat{$name} eq '' && exists ($self -> {default})) ;
49 my $span = 0 ;
50 $self -> show_label ($req);
51 -]
52 </td>
53 </tr>
54 <tr>
55 <td class="ef-control-box ef-control-box-width-full">
56 [-
57 local $self -> {width_percent} = 'full' ;
58 $self -> show_control ($req)
59 -]
60 </td>
61 </tr>
62 </table>
63 [$endif$]
64 [$endsub$]
65
66 [# ---------------------------------------------------------------------------
67 #
68 # show_control - output the control
69 #]
70
71 [$ sub show_control ($self, $req)
72 my $class = $self -> {class} ||= '' ;
73 my ($attrs, $ctrlid, $name) = $self -> get_std_control_attr($req) ;
74 $]
75
76 <textarea type="text" name="[+ $self -> {force_name} || $self -> {name} +]" [+ do { local $escmode = 0 ; $attrs} +]
77 [# [$if $self -> {cols} $]cols="[+ $self->{cols} +]"[$endif$] #]
78 [$if $self -> {rows} $]rows="[+ $self->{rows} +]"[$endif$]
79 ></textarea>
80 [* return $ctrlid ; *]
81 [$endsub$]
82
83
84 [# ---------------------------------------------------------------------------
85 #
86 # show_control_readonly - output the control as readonly
87 #]
88
89 [$ sub show_control_readonly ($self, $req, $value, $class) $]
90 [-
91 $value //= $fdat{$self -> {name}} ;
92 $value =~ s/\s*$// ;
93 $value =~ s/^\s*// ;
94 @value = split (/\n/, $value) ;
95 $i = 0 ;
96 -][$ foreach my $val (@value) $]
97 [$ if $val =~ /^\s*$/ $]<br>[$else$]
98 [- $self -> SUPER::show_control_readonly ($req, $val, $class) -][# $ if ($i < @value - 1) $]<br>[$endif$ #]
99 [$endif$]
100 [$endforeach$]
101 [$endsub$]
102 __END__
103
104 =pod
105
106 =head1 NAME
107
108 Embperl::Form::Control::textarea - A textarea input control inside an Embperl Form
109
110
111 =head1 SYNOPSIS
112
113 {
114 type => 'textarea',
115 text => 'blabla',
116 name => 'foo',
117 id => 'id_foo',
118 rows => 10,
119 cols => 80,
120 }
121
122 =head1 DESCRIPTION
123
124 Used to create an input control inside an Embperl Form.
125 See Embperl::Form on how to specify parameters.
126
127 =head2 PARAMETER
128
129 =head3 type
130
131 Needs to be 'textarea'
132
133 =head3 text
134
135 Will be used as label for the text input control
136
137 =head3 name
138
139 Will be used as field name for the text input control
140
141 =head3 name
142
143 Will be used as id of the text input control
144
145 =head3 cols
146
147 Number of columns
148
149 =head3 rows
150
151 Number of rows
152
153 =head1 Author
154
155 G. Richter (richter at embperl dot org)
156
157 =head1 See Also
158
159 perl(1), Embperl, Embperl::Form
160
161