You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Ted <mp...@netcasters.com> on 2006/10/17 17:58:26 UTC
Apache2::Request param repetitions
Hi,
I am using the param method to retrieve form data. I have a checkbox
field called user_status which has three values: Active, Inactive and
Deleted.
If all three boxes are checked and the form is submitted, the user_status
field is returned by the param method three times. This seems redundant and
am wondering if this was intended or a bug.
Apache 2.2.3
mod_perl 2.0.2
libapreq 2.0.8
Thanks,
Ted
Code looks like this:
--------------------
my $ar = Apache2::Request->new($r);
foreach $key ($ar->param()) {
if ($key eq 'user_status') {
warn "$key\n";
foreach ($ar->param($key)) {
warn "-- $_\n";
}
}
}
Output looks like this:
----------------------
user_status
-- Active
-- Inactive
-- Deleted
user_status
-- Active
-- Inactive
-- Deleted
user_status
-- Active
-- Inactive
-- Deleted
Re: Apache2::Request param repetitions
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Ted wrote:
> That's true, I could do that, but my aim is to have a general purpose
> form reader. I want to loop through all form elements and load
> up a hash for processing later. I could put all encountered param
> names in a hash prior to processing, to eliminate the problem, but
> thought the issue was worth mentioning.
# returns ref to APR::Request::Param::Table object representing
# all (args + body) params
my $table = $req->param;
@table_keys = keys %$table;
--
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F 6A47 D55A 7172 A799 97F
When I call your name, Girl, it starts to flame
Burning in my heart, Tearing it all apart..
No matter how I try My love I cannot hide....
Re: Apache2::Request param repetitions
Posted by Ted <mp...@netcasters.com>.
That's true, I could do that, but my aim is to have a general purpose
form reader. I want to loop through all form elements and load
up a hash for processing later. I could put all encountered param
names in a hash prior to processing, to eliminate the problem, but
thought the issue was worth mentioning.
Thanks,
Ted
Jonathan wrote:
> i think its because of the way that you're looping it...
>
> the browser sends
> user_status= active
> user_status= inactive
> user_status= deleted
> and your loop is picking up all 3
>
> if you call param('user_status') you should just get an array of
> ['active','inactive','deleted']
Re: Apache2::Request param repetitions
Posted by Jonathan <jv...@2xlp.com>.
i think its because of the way that you're looping it...
the browser sends
user_status= active
user_status= inactive
user_status= deleted
and your loop is picking up all 3
if you call param('user_status') you should just get an array of
['active','inactive','deleted']