summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-input-text.html
blob: f71f2f7fb768417f622dc8d294a3363be7ca0bd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<% include('tr-td-label.html', @_ ) %>

  <TD <% $cell_style %>>

    <% $opt{'prefix'} %><INPUT TYPE  = "<% $opt{type} || 'text' %>"
                               NAME  = "<% $opt{field} %>"
                               ID    = "<% $opt{id} %>"
                               VALUE = "<% $value |h %>"
                               <% $size %>
                               <% $maxlength %>
                               <% $style %>
                               <% $opt{disabled} %>
                               <% $onchange %>
                        ><% $opt{'postfix'} %>

  </TD>

</TR>

<%init>

my %opt = @_;

my $value = length($opt{curr_value}) ? $opt{curr_value} : $opt{value};

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $size = $opt{'size'}
             ? 'SIZE="'. $opt{'size'}. '"'
             : '';

my $maxlength = $opt{'maxlength'}
                ? 'MAXLENGTH="'. $opt{'maxlength'}. '"'
                : '';

$opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
  if ref($opt{'disabled'}) eq 'CODE';
$opt{'disabled'} = 'DISABLED'
  if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?

my @style = ();

push @style, 'text-align: '. $opt{'text-align'}
  if $opt{'text-align'};

push @style, 'background-color: #dddddd'
  if $opt{'disabled'};

my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';

my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

</%init>