Using the aforementioned HTML::Template is a good solution to repopulating an HTML form after Perl-side validation. I do this all day long. H::T has a built-in function that preserves the values from the form:

... my $query = new CGI; ... my $template = HTML::Template->new( filename => "foobar.tmpl", associate => $query);

However, one problem in any of the methods described above, is resetting radio buttons, check boxes, or select/option dropdowns. Besides using the associate function in H::T, you need to set your returning params to trigger which buttons, boxes, or dropdowns have been selected. Here's my messy solution (I'm open to new ways, monks):

Perl: my $vote = $query->param('vote'); my ($voteyes, $voteno); if ($vote == 1) { $voteyes == 1; } elsif ($vote == 2) { $voteno == 1; } $template = param(voteyes => $voteyes, voteno => $voteno); HTML: Yes: <input type="radio" name="vote" value="1"<tmpl_if voteyes> checke +d</tmpl_if> /> No: <input type="radio" name="vote" value="2"<tmpl_if voteno> checked< +/tmpl_if> />

Just a friendly "heads-up." Good luck.


—Brad
"Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton

In reply to Re: Remembering values from an HTML form by bradcathey
in thread Remembering values from an HTML form by Nevtlathiel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.