2
package CGI::FormBuilder::Field::static;
6
CGI::FormBuilder::Field::static - FormBuilder class for static fields
10
use CGI::FormBuilder::Field;
12
# delegated straight from FormBuilder
13
my $f = CGI::FormBuilder::Field->new($form,
21
our $VERSION = '3.03';
23
use CGI::FormBuilder::Util;
24
use CGI::FormBuilder::Field;
25
use base 'CGI::FormBuilder::Field';
27
# The majority of this module's methods (including new) are
28
# inherited directly from ::base, since they involve things
29
# which are common, such as parameter parsing. The only methods
30
# that are individual to different fields are those that affect
31
# the rendering, such as script() and tag()
34
return ''; # static fields get no messages
39
local $^W = 0; # -w sucks
41
my $attr = $self->attr;
43
my $jspre = $self->{_form}->jsprefix;
46
my @value = $self->tag_value; # sticky is different in <tag>
47
my @opt = $self->options;
48
debug 2, "my(@opt) = \$field->options";
50
# Add in our "Other:" option if applicable
51
push @opt, [$self->othername, $self->{_form}{messages}->form_other_default]
54
debug 2, "$self->{name}: generating $attr->{type} input type";
56
# static fields are actually hidden
57
$attr->{type} = 'hidden';
59
# We iterate over each value - this is the only reliable
60
# way to handle multiple form values of the same name
61
# (i.e., multiple <input> or <hidden> fields)
62
@value = (undef) unless @value; # this creates a single-element array
64
for my $value (@value) {
68
$attr->{value} = $value; # override
69
delete $attr->{value} unless defined $value;
72
$tmp .= htmltag('input', $attr);
75
# If we have options, lookup the label instead of the true value
76
# to print next to the field. This will happen when radio/select
77
# lists are converted to 'static'.
80
my($o,$n) = optval($_);
82
$n ||= $attr->{labels}{$o} || ($self->nameopts ? toname($o) : $o);
88
# print the value out too when in a static context
89
$tmp .= escapehtml($value);
93
debug 2, "$self->{name}: generated tag = @tag";
94
return join ' ', @tag; # always return scalar tag
103
This module is used to create B<FormBuilder> elements of a specific type.
104
Currently, each type module inherits all of its methods from the main
105
L<CGI::FormBuilder::Field> module except for C<tag()> and C<script()>,
106
which affect the XHMTL representation of the field.
108
Please refer to L<CGI::FormBuilder::Field> and L<CGI::FormBuilder> for
113
L<CGI::FormBuilder>, L<CGI::FormBuilder::Field>
117
$Id: static.pm,v 1.12 2006/02/24 01:42:29 nwiger Exp $
121
Copyright (c) 2005-2006 Nate Wiger <nate@wiger.org>. All Rights Reserved.
123
This module is free software; you may copy this under the terms of
124
the GNU General Public License, or the Artistic License, copies of
125
which should have accompanied your Perl kit.