Skip Menu |

This queue is for tickets about the AxKit-XSP-PerForm CPAN distribution.

Report information
The Basics
Id: 7791
Status: new
Priority: 0/
Queue: AxKit-XSP-PerForm

People
Owner: Nobody in particular
Requestors: peter.mueller [...] elimpex.com
Cc:
AdminCc:

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



Subject: disabled textvield throws exception on submit; checkbox validation get wrong parameters
If a textfield has attribute or subtag "disabled" ist is correctly flagged disabled, but when a submit button is pressed an exception is thrown. If a checkbox is given an index attribute and the box is NOT checked, the index value is given as the second argument to the validate_ function. If it is checked the value is correctly assigned, and the index is given as third parameter... Both errors seem to be a problem with the get method of Apache::Table which does not return an array at all if the requested parameter is not returned by the browser. So code like this fails: textfield => { ... value => ($params->get($name.$index))[-1], ... } I repleaced $params->get($name.$index))[-1] by $params->get($name.$index))[-1] || undef at two places and the above errors disappeared. I have not enough inside knowledge of PerForm.pm if this should be done to all other occurences of such code. I added a patch showing my changes Bye, Peter Elimpex Versions used: PerForm 1.83 # $Id: PerForm.pm,v 1.24 2003/08/10 16:43:56 matt Exp $ perl -v: This is perl, v5.8.0 built for i586-linux-thread-multi
Sorry, here is the patch By, Peter Elimpex
--- PerForm.pm.org 2004-09-28 11:54:39.000000000 +0200 +++ PerForm.pm 2004-09-28 12:02:20.000000000 +0200 @@ -216,7 +216,7 @@ width => $width, maxlength => $maxlength, name => $name, - value => ($params->get($name.$index))[-1], + value => ($params->get($name.$index))[-1] || undef, index => $index, ($disabled ? (disabled => $disabled) : ()), ($onchange ? (onchange => $onchange) : ()), @@ -358,7 +358,7 @@ } # load elsif (my $sub = $package->can($onload || "load_${name}")) { - my @vals = $sub->($ctxt, $value, ($params->get($name.$index))[-1], $index); + my @vals = $sub->($ctxt, $value, ($params->get($name.$index))[-1] || undef, $index); $checked = shift @vals; $value = shift @vals if @vals; }
[guest - Tue Sep 28 06:32:02 2004]: Another Sorry! In removing debugging code, I also removed and destroyed the fix, ups. This should "really" fix the checkbox problem. But I still dont know if I should add "|| undef" or similar to all Apache::Table get operations ... Bye, Peter Elimpex
--- PerForm.pm 2004-09-28 16:01:11.000000000 +0200 +++ PerForm.pm.org 2004-09-28 11:54:39.000000000 +0200 @@ -216,7 +216,7 @@ width => $width, maxlength => $maxlength, name => $name, - value => ($params->get($name.$index))[-1] || undef, + value => ($params->get($name.$index))[-1], index => $index, ($disabled ? (disabled => $disabled) : ()), ($onchange ? (onchange => $onchange) : ()), @@ -348,7 +348,7 @@ if ($params->{"__submitting_$fname"}) { if (my $sub = $package->can($onval || "validate_${name}")) { eval { - $sub->($ctxt, ($params->get($name.$index))[-1] || 0, $index); + $sub->($ctxt, ($params->get($name.$index))[-1], $index); $params->{$name.$index} = ($params->get($name.$index))[-1]; }; $error = $@; @@ -358,7 +358,7 @@ } # load elsif (my $sub = $package->can($onload || "load_${name}")) { - my @vals = $sub->($ctxt, $value, ($params->get($name.$index))[-1] || 0, $index); + my @vals = $sub->($ctxt, $value, ($params->get($name.$index))[-1], $index); $checked = shift @vals; $value = shift @vals if @vals; }