If you look at the source code of CGI, you can discover the code inside end_form that is adding all the extra hidden variables.

sub end_form { my($self,@p) = self_or_default(@_); if ( $NOSTICKY ) { return wantarray ? ("</form>") : "\n</form>"; } else { if (my @fields = $self->get_fields) { return wantarray ? ("<div>",@fields,"</div>","</form>") : "<div>".(join '',@fields)."</div>\n</fo +rm>"; } else { return "</form>"; } } }

As you can see above, the $NOSTICKY global will prevent the extra hidden fields that lead to the undesired default values. After reading the documentation of $NOSTICKY, you can set this in two different ways. One of them is more global:

use CGI qw(-nosticky);

Or you can is isolate the change to just the end_form function by doing the following:

print do {local $CGI::NOSTICKY = 1; $q->end_form()} . "\n";

Or you can just simplify the whole process for yourself by writing a simple </form> tag. Really don't know why someone wouldn't just do that anyway as the CGI module really does try to do too much in my opinion.

- Miller

In reply to Re^3: How to get unselected radio_group() items after submitting form by wind
in thread How to get unselected radio_group() items after submitting form by slugger415

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.