| 1 | |||||||||||||||||||||||||||||
| 2 | ########################################################################### | ||||||||||||||||||||||||||||
| 3 | # Copyright (c) Nate Wiger http://nateware.com. All Rights Reserved. | ||||||||||||||||||||||||||||
| 4 | # Please visit http://formbuilder.org for tutorials, support, and examples. | ||||||||||||||||||||||||||||
| 5 | ########################################################################### | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | package CGI::FormBuilder::Template::Builtin; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | CGI::FormBuilder::Template::Builtin - Builtin HTML rendering | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | my $form = CGI::FormBuilder->new; | ||||||||||||||||||||||||||||
| 16 | $form->render; | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 4 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 4 | ▶ | use CGI::FormBuilder::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | our $VERSION = '3.10'; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | sub new { | ||||||||||||||||||||||||||||
| 31 | 58 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 58 | ▶ | my $class = ref($self) || $self; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 33 | 58 | ▶ | my %opt = @_ if @_ > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 58 | return bless \%opt, $class; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub prepare { | ||||||||||||||||||||||||||||
| 38 | 58 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
prepare: called CC=58 SCAR=43.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 58 | my $form = shift; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 58 | my @html = (); # joined with newline | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # Opening CGI/title gunk | ||||||||||||||||||||||||||||
| 44 | 58 | my $hd = $form->header; | |||||||||||||||||||||||||||
| 45 | 58 | ▶ | if (defined $hd) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 14 | push @html, $form->dtd, htmltag('head'); | |||||||||||||||||||||||||||
| 47 | 14 | ▶ | push @html, htmltag('title') . $form->title . htmltag('/title') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | if $form->title; | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | # stylesheet path if specified | ||||||||||||||||||||||||||||
| 51 | 14 | ▶ | if ($form->{stylesheet} && $form->{stylesheet} ne 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$form->{"stylesheet"} and $form->{"stylesheet"} ne 1
MC/DC100%2/2
$form->{"stylesheet"} and $form->{"stylesheet"} ne 1
$form->{"stylesheet"}
$form->{"stylesheet"} ne 1
Truth table100%3/3
A and B
A= $form->{"stylesheet"}B= $form->{"stylesheet"} ne 1
| |||||||||||||||||||||||||||||
| 52 | # user-specified path | ||||||||||||||||||||||||||||
| 53 | push @html, htmltag('link', { rel => 'stylesheet', | ||||||||||||||||||||||||||||
| 54 | type => 'text/css', | ||||||||||||||||||||||||||||
| 55 | 4 | href => $form->{stylesheet} }); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # JavaScript validate/head functions | ||||||||||||||||||||||||||||
| 60 | 58 | my $js = $form->script; | |||||||||||||||||||||||||||
| 61 | 58 | ▶ | push @html, $js if $js; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | # Opening HTML if so requested | ||||||||||||||||||||||||||||
| 64 | 58 | my $font = $form->font; | |||||||||||||||||||||||||||
| 65 | 58 | ▶ | my $fcls = $font ? htmltag('/font') : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 58 | ▶ | if (defined $hd) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 14 | push @html, htmltag('/head'), $form->body; | |||||||||||||||||||||||||||
| 68 | 14 | ▶ | push @html, $font if $font; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 14 | ▶ | push @html, htmltag('h3') . $form->title . htmltag('/h3') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | if $form->title; | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # Include warning if noscript | ||||||||||||||||||||||||||||
| 74 | 58 | ▶ | push @html, $form->noscript if $js; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # Put id's around state tags if so required | ||||||||||||||||||||||||||||
| 77 | 58 | my($stid, $keid); | |||||||||||||||||||||||||||
| 78 | 58 | ▶ | if (my $fn = $form->name) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 8 | $stid = tovar("${fn}$form->{statename}"); | |||||||||||||||||||||||||||
| 80 | 8 | $keid = tovar("${fn}$form->{extraname}"); | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # Begin form | ||||||||||||||||||||||||||||
| 84 | 58 | my $txt = $form->text; | |||||||||||||||||||||||||||
| 85 | 58 | ▶ | push @html, $txt if $txt; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 58 | push @html, $form->start; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # Put id's around state tags if they exist | ||||||||||||||||||||||||||||
| 89 | 58 | ▶ | if (my $st = $form->statetags) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 58 | push @html, | |||||||||||||||||||||||||||
| 91 | $form->div(id => $form->idname($form->statename), | ||||||||||||||||||||||||||||
| 92 | class => $form->class($form->statename)) . | ||||||||||||||||||||||||||||
| 93 | $st . htmltag('/div'); | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 58 | ▶ | if (my $ke = $form->keepextras) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 4 | push @html, | |||||||||||||||||||||||||||
| 97 | $form->div(id => $form->idname($form->extraname), | ||||||||||||||||||||||||||||
| 98 | class => $form->class($form->extraname)) . | ||||||||||||||||||||||||||||
| 99 | $ke . htmltag('/div'); | ||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | # Render hidden fields first | ||||||||||||||||||||||||||||
| 103 | 58 | my @unhidden; | |||||||||||||||||||||||||||
| 104 | 58 | for my $field ($form->fieldlist) { | |||||||||||||||||||||||||||
| 105 | 169 | ▶ | push(@unhidden, $field), next if $field->type ne 'hidden'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 106 | 2 | push @html, $field->tag; # no label/etc for hidden fields | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | # Support fieldset => 'name' to organize by fieldset on the fly | ||||||||||||||||||||||||||||
| 110 | 58 | my $legend = $form->fieldsets; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | # Get table stuff and reused calls | ||||||||||||||||||||||||||||
| 113 | 58 | my $table = $form->table(id => $form->idname($form->bodyname), class => $form->class); | |||||||||||||||||||||||||||
| 114 | 58 | my $tabn = 1; | |||||||||||||||||||||||||||
| 115 | 58 | ▶ | push @html, $table if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | # Render regular fields in table | ||||||||||||||||||||||||||||
| 118 | 58 | my $lastset; | |||||||||||||||||||||||||||
| 119 | 58 | for my $field (@unhidden) { | |||||||||||||||||||||||||||
| 120 | 167 | ▶ | if (my $set = $field->fieldset) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 121 | # hooks (hack?) for fieldsets | ||||||||||||||||||||||||||||
| 122 | 9 | ▶ | if ($set ne $lastset) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | # close any open tables/fieldsets | ||||||||||||||||||||||||||||
| 124 | 4 | ▶ | if ($lastset) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 125 | 3 | ▶ | push @html, htmltag('/table') if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 3 | push @html, htmltag('/fieldset'); | |||||||||||||||||||||||||||
| 127 | 3 | push @html, htmltag('/div'); | |||||||||||||||||||||||||||
| 128 | } elsif ($table) { | ||||||||||||||||||||||||||||
| 129 | # Catch in case we have an empty table - ie the previous | ||||||||||||||||||||||||||||
| 130 | # element is just <table>. This workaround is needed | ||||||||||||||||||||||||||||
| 131 | # in case the user wants to mix fields with/without | ||||||||||||||||||||||||||||
| 132 | # fieldsets in the same form | ||||||||||||||||||||||||||||
| 133 | 1 | ▶ | if ($html[-1] =~ /^<table\b/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 1 | pop @html; | |||||||||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||||||||||
| 136 | # close non-fieldset table | ||||||||||||||||||||||||||||
| 137 | 0 | push @html, htmltag('/table'); | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | # Wrap fieldset in a <div> to allow jquery #tabs | ||||||||||||||||||||||||||||
| 142 | 4 | push @html, $form->div(id => $form->idname($form->tabname.$tabn++), | |||||||||||||||||||||||||||
| 143 | class => $form->class($form->tabname)); | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 4 | (my $sn = lc $set) =~ s/\W+/_/g; | |||||||||||||||||||||||||||
| 146 | 4 | push @html, htmltag('fieldset', id => $form->idname("_$sn"), | |||||||||||||||||||||||||||
| 147 | class => $form->class('_set')); | ||||||||||||||||||||||||||||
| 148 | push @html, htmltag('legend') . ($legend->{$set}||$set) . htmltag('/legend') | ||||||||||||||||||||||||||||
| 149 | 4 | ▶ | if defined $legend->{$set}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$legend->{$set} || $set
MC/DC0%0/2
$legend->{$set} || $set
$legend->{$set}
$set
Truth table33%1/3
A || B
A= $legend->{$set}B= $set
| |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | # Wrap fields in a table | ||||||||||||||||||||||||||||
| 152 | 4 | ▶ | push @html, $form->table if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 4 | $lastset = $set; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | } elsif ($lastset) { | ||||||||||||||||||||||||||||
| 157 | # ended <fieldset> defs before form has ended | ||||||||||||||||||||||||||||
| 158 | # remaining fields are not in a fieldset | ||||||||||||||||||||||||||||
| 159 | 1 | ▶ | push @html, htmltag('/table') if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 1 | push @html, htmltag('/fieldset'); | |||||||||||||||||||||||||||
| 161 | 1 | push @html, htmltag('/div'); | |||||||||||||||||||||||||||
| 162 | 1 | ▶ | push @html, $table if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 1 | undef $lastset; # avoid dup </fieldset> below | |||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 167 | debug 2, "render: attacking normal field '$field'"; | |||||||||||||||||||||||||||
| 167 | 167 | ▶ | next if $field->static > 1 && ! $field->tag_value; # skip missing static vals | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$field->static > 1 and not $field->tag_value
MC/DC0%0/2
$field->static > 1 and not $field->tag_value
$field->static > 1
not $field->tag_value
Truth table33%1/3
A and not(B)
A= $field->static > 1B= not $field->tag_value
| |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 167 | ▶ | if ($table) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 165 | push @html, $form->tr(id => $form->idname("_$field", $form->rowname)); | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 165 | my $cl = $form->class($form->labelname); | |||||||||||||||||||||||||||
| 173 | 165 | my $row = ' ' . $form->td(id => $form->idname("_$field", $form->labelname), | |||||||||||||||||||||||||||
| 174 | class => $cl) . $font; | ||||||||||||||||||||||||||||
| 175 | 165 | ▶ | if ($field->invalid) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 176 | 2 | $row .= $form->invalid_tag($field->label); | |||||||||||||||||||||||||||
| 177 | ▶ | } elsif ($field->required && ! $field->static) { | |||||||||||||||||||||||||||
|
Condition66%2/3
$field->required and not $field->static
MC/DC50%1/2
$field->required and not $field->static
$field->required
not $field->static
Truth table66%2/3
A and not(B)
A= $field->requiredB= not $field->static
| |||||||||||||||||||||||||||||
| 178 | 34 | $row .= $form->required_tag($field->label); | |||||||||||||||||||||||||||
| 179 | } else { | ||||||||||||||||||||||||||||
| 180 | 129 | $row .= $field->label; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | 165 | $row .= $fcls . htmltag('/td'); | |||||||||||||||||||||||||||
| 183 | 165 | push @html, $row; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # tag plus optional errors and/or comments | ||||||||||||||||||||||||||||
| 186 | 165 | $row = ''; | |||||||||||||||||||||||||||
| 187 | 165 | ▶ | if ($field->invalid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 2 | $row .= ' ' . $field->message; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 165 | ▶ | if ($field->comment) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 11 | ▶ | $row .= ' ' . $field->comment unless $field->static; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | 165 | $row = $field->tag . $row; | |||||||||||||||||||||||||||
| 194 | 165 | $cl = $form->class($form->{fieldname}); | |||||||||||||||||||||||||||
| 195 | 165 | push @html, (' ' . $form->td(id => $form->idname("_$field", $form->fieldname), | |||||||||||||||||||||||||||
| 196 | class => $cl) . $font | ||||||||||||||||||||||||||||
| 197 | . $row . $fcls . htmltag('/td')); | ||||||||||||||||||||||||||||
| 198 | 165 | push @html, htmltag('/tr'); | |||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||
| 200 | # no table | ||||||||||||||||||||||||||||
| 201 | 2 | my $row = $font; | |||||||||||||||||||||||||||
| 202 | 2 | ▶ | if ($field->invalid) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 203 | 0 | $row .= $form->invalid_tag($field->label); | |||||||||||||||||||||||||||
| 204 | ▶ | } elsif ($field->required && ! $field->static) { | |||||||||||||||||||||||||||
|
Condition33%1/3
$field->required and not $field->static
MC/DC0%0/2
$field->required and not $field->static
$field->required
not $field->static
Truth table33%1/3
A and not(B)
A= $field->requiredB= not $field->static
| |||||||||||||||||||||||||||||
| 205 | 0 | $row .= $form->required_tag($field->label); | |||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||
| 207 | 2 | $row .= $field->label; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | 2 | $row .= $fcls; | |||||||||||||||||||||||||||
| 210 | 2 | push @html, $row; | |||||||||||||||||||||||||||
| 211 | 2 | push @html, $field->tag; | |||||||||||||||||||||||||||
| 212 | 2 | ▶ | push @html, $field->message if $field->invalid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 2 | ▶ | push @html, $field->comment if $field->comment; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 2 | ▶ | push @html, '<br />' if $form->linebreaks; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | # Close fieldset before [Submit] if using fieldsets | ||||||||||||||||||||||||||||
| 219 | 58 | ▶ | if ($lastset) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | push @html, htmltag('/table') if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 0 | push @html, htmltag('/fieldset'); | |||||||||||||||||||||||||||
| 222 | 0 | push @html, htmltag('/div'); | |||||||||||||||||||||||||||
| 223 | 0 | undef $table; # avoid dup </table> below | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | # Throw buttons in a colspan | ||||||||||||||||||||||||||||
| 227 | 58 | my $buttons = $form->reset . $form->submit; | |||||||||||||||||||||||||||
| 228 | 58 | ▶ | if ($buttons) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 55 | my $row = ''; | |||||||||||||||||||||||||||
| 230 | 55 | ▶ | if ($table) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 53 | my $c = $form->class($form->{submitname}); | |||||||||||||||||||||||||||
| 232 | 53 | ▶ | my %a = $c ? () : (align => 'center'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 53 | $row .= $form->tr(id => $form->idname($form->submitname, $form->rowname)) . "\n " | |||||||||||||||||||||||||||
| 234 | . $form->td(id => $form->idname($form->submitname, $form->fieldname), | ||||||||||||||||||||||||||||
| 235 | class => $c, colspan => 2, %a) . $font; | ||||||||||||||||||||||||||||
| 236 | } else { | ||||||||||||||||||||||||||||
| 237 | # wrap in a <div> for fieldsets | ||||||||||||||||||||||||||||
| 238 | 2 | $row .= $form->div(id => $form->idname('_controls'), | |||||||||||||||||||||||||||
| 239 | class => $form->class('_controls')); | ||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | 55 | $row .= $buttons; | |||||||||||||||||||||||||||
| 242 | 55 | ▶ | if ($table) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 53 | ▶ | $row .= htmltag('/font') if $font; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 53 | ▶ | $row .= htmltag('/td') . "\n" . htmltag('/tr') if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | } else { | ||||||||||||||||||||||||||||
| 246 | 2 | $row .= htmltag('/div'); | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | 55 | push @html, $row; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | # Properly nest closing tags | ||||||||||||||||||||||||||||
| 252 | 58 | ▶ | push @html, htmltag('/table') if $table; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 58 | push @html, htmltag('/form'); # $form->end | |||||||||||||||||||||||||||
| 254 | 58 | ▶ | push @html, htmltag('/font') if $font && defined $hd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$font and defined $hd
MC/DC0%0/2
$font and defined $hd
$font
defined $hd
Truth table33%1/3
A and B
A= $fontB= defined $hd
| |||||||||||||||||||||||||||||
| 255 | 58 | ▶ | push @html, htmltag('/body'),htmltag('/html') if defined $hd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | # Always return scalar since print() is a list function | ||||||||||||||||||||||||||||
| 258 | 58 | return $self->{output} = join("\n", @html) . "\n" | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | sub render { | ||||||||||||||||||||||||||||
| 262 | 58 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
render: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 263 | 58 | return $self->{output}; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 4 | 1; | |||||||||||||||||||||||||||
| 267 | __END__ | ||||||||||||||||||||||||||||