CGI-Application-3.31: need override=>1 or not?

M

mjl69

A slightly altered cut & paste from CGI-Application that works:

sub do_stuff
{
my $self = shift;

# Get CGI query object
my $q = $self->query();

my $output = '';
$output .= $q->start_html(-title => 'Page One');
$output .= $q->h1("Hello, This is page one!");
$output .= $q->start_form();
$output .= $q->hidden(-name => 'rm', -value => 'mode2', -override => 1);
$output .= $q->submit();
$output .= $q->end_form();
$output .= $q->end_html();

return $output;
}

Actual sample code from CGI-Application that does not work as expected

sub showform {
my $self = shift;

# Get CGI query object
my $q = $self->query();

my $output = '';
$output .= $q->start_html(-title => 'Widget Search Form');
$output .= $q->start_form();
$output .= $q->textfield(-name => 'widgetcode');
$output .= $q->hidden(-name => 'rm', -value => 'mode2'); #note no override
$output .= $q->submit();
$output .= $q->end_form();
$output .= $q->end_html();

return $output;
}

I was wondering why my CGI app was not going to the next page, but it was fixed by adding the override. I saw that
Sam Tregar did it this way in his book. Why does CGI-Application document it without override? I assumed that as an
extension of CGI, that the author had done away with stickiness internally.

mjl
 
A

Alan Mead

I was wondering why my CGI app was not going to the next page, but it was fixed by adding the override. I saw that
Sam Tregar did it this way in his book. Why does CGI-Application document it without override? I assumed that as an
extension of CGI, that the author had done away with stickiness internally.

I don't know but there is a note in the CGI.pm documentation .. something
like "The behavior of hidden() with respect to stickiness has changed
again"

I find that stickiness is magical in some cases but in cases like yours it
can be annoying. If you can always remember to override, then fine.
Otherwise, it's pretty trivial to write your own myhidden() (or mystate())
that ignores stickiness. Or just emit the HTML (it's only a few
extra characters).

-Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top