Changeset 15 in text-formbuilder for trunk/lib/Text


Ignore:
Timestamp:
11/02/04 10:09:45 (20 years ago)
Author:
peter
Message:

added invalid field class CSS hook
moved descirption from full tempalte to form template

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Text/FormBuilder.pm

    r14 r15  
    157157use CGI::FormBuilder; 
    158158 
    159 sub form { 
     159sub get_form { 
    160160    my \$cgi = shift; 
    161161    my \$cgi_form = CGI::FormBuilder->new( 
     
    204204 
    205205sub _form_template { 
    206 q[<p id="instructions">(Required fields are marked in <strong>bold</strong>.)</p> 
     206q[<% $description ? qq[<p id="description">$description</p>] : '' %> 
     207<% (grep { $_->{required} } @fields) ? qq[<p id="instructions">(Required fields are marked in <strong>bold</strong>.)</p>] : '' %> 
    207208<% $start %> 
    208209<table> 
    209210<% my $i; foreach(@fields) { 
    210211    $OUT .= qq[  <tr><th class="sectionhead" colspan="2"><h2>$headings[$i]</h2></th></tr>\n] if $headings[$i]; 
    211     $OUT .= qq[  <tr>]; 
     212    $OUT .= $$_{invalid} ? qq[  <tr class="invalid">] : qq[  <tr>]; 
    212213    $OUT .= '<th class="label">' . ($$_{required} ? qq[<strong class="required">$$_{label}:</strong>] : "$$_{label}:") . '</th>'; 
    213     $OUT .= qq[<td>$$_{field} $$_{comment}</td></tr>\n]; 
     214    if ($$_{invalid}) { 
     215        $OUT .= qq[<td>$$_{field} $$_{comment} Missing or invalid value.</td></tr>\n]; 
     216    } else { 
     217        $OUT .= qq[<td>$$_{field} $$_{comment}</td></tr>\n]; 
     218    } 
    214219    $i++; 
    215220} %> 
     
    237242<h1><% $title %></h1> 
    238243<% $author ? qq[<p id="author">Created by $author</p>] : '' %> 
    239 <% $description ? qq[<p id="description">$description</p>] : '' %> 
    240244] . $self->_form_template . q[ 
    241245<hr /> 
Note: See TracChangeset for help on using the changeset viewer.