Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 52646
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: Nobody in particular
Requestors: michaelgang [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: using cgi hidden when name of the param was already set ignores -value tag
Date: Thu, 10 Dec 2009 11:20:09 +0200
To: bug-CGI.pm [...] rt.cpan.org
From: Michael Gang <michaelgang [...] gmail.com>
Download (untitled) / with headers
text/plain 386b
Hi all, In the following script i would expect use CGI; use strict; use warnings; my $cgi = CGI->new(); $cgi->param('a','b'); my $input = $cgi->hidden(-name=>'a', -value=>'c',); print $input; That i would get <input type="hidden" name="a" value="c" />. I get the input <input type="hidden" name="a" value="b" /> Why do i get it ? Thanks, David
Subject: Re: [rt.cpan.org #52646] using cgi hidden when name of the param was already set ignores -value tag
Date: Thu, 10 Dec 2009 12:27:54 -0500
To: bug-CGI.pm [...] rt.cpan.org
From: Yanick Champoux <yanick.champoux [...] gmail.com>
Download (untitled) / with headers
text/plain 917b
On December 10, 2009 04:20:41 am michael gang via RT wrote: Show quoted text
> $cgi->param('a','b'); > my $input = $cgi->hidden(-name=>'a', > -value=>'c',); > > print $input; > > That i would get <input type="hidden" name="a" value="c" />. > > I get the input <input type="hidden" name="a" value="b" /> > > Why do i get it ?
hidden() will consider 'c' to be the default, which is replaced by the 'b' given as param. If you really want 'c', no matter what was submitted to the url, you can use the '-override' attribute: my $cgi = CGI->new(); $cgi->param( 'a', 'b' ); my $input = $cgi->hidden( -name => 'a', -value => 'c', -override => 1, ); print $input; [yanick@byakko CGI.pm (b2c)]$ perl -Ilib t/b2c.t 1..1 <input type="hidden" name="a" value="c" /> See the 'CREATING FILL-OUT FORMS' section of the CGI pod for more detailed explanations about this behavior. `/anick
Thanks the answer, Yanick. Marking as resolved.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.