Skip Menu |

This queue is for tickets about the Class-DBI-AsForm CPAN distribution.

Report information
The Basics
Id: 12064
Status: open
Priority: 0/
Queue: Class-DBI-AsForm

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

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



Date: Tue, 29 Mar 2005 20:20:40 -0500
From: Sai Tong <sai.tong [...] gmail.com>
To: bug-Class-DBI-AsForm [...] rt.cpan.org
Subject: "to_field not returning content with $how" bug still in released version of 2.3, 2.4 and 2.41?
I noticed that this bug: ("return $class->$meth($field);" in sub to_field changed to "return $self ->$meth($field);" in sub to_field ) was supposed to already be fixed in version 2.3 based on the Change Log and Bugs Reports in the CPAN site of Class-DBI-AsForm.pm. But it seems that in the CPAN released versions of 2.3, 2.4 and 2.41, this bug is still in AsForm.pm. Or am I missing something by mistake? S. Tong
From: info [...] whawes.co.uk
Seconded. This bug is still present in 2.42. Attached is a patch against 2.42 to fix it.
--- AsForm.2.42.pm Thu Sep 22 09:24:12 2005 +++ AsForm.pm Thu Sep 22 09:27:24 2005 @@ -86,7 +86,7 @@ if ($how and $how =~ /^(text(area|field)|select)$/) { no strict 'refs'; my $meth = "_to_$how"; - return $class->$meth($field); + return $self->$meth($field); } my $hasa = $class->__hasa_rels->{$field}; return $self->_to_select($field, $hasa->[0])
Date: Tue, 4 Oct 2005 07:39:18 +0100
From: Tony Bowden <tony [...] kasei.com>
To: Guest via RT <bug-Class-DBI-AsForm [...] rt.cpan.org>
Subject: Re: [cpan #12064] "to_field not returning content with $how" bug still in released version of 2.3, 2.4 and 2.41?
RT-Send-Cc:
On Thu, Sep 22, 2005 at 04:29:20AM -0400, Guest via RT wrote: Show quoted text
> Seconded. This bug is still present in 2.42. Attached is a patch against > 2.42 to fix it.
It'll be fixed much quicker with a patch to the test file to show the problem. Obviously fixing the code isn't the problems. It's making sure that this doesn't come back again. Thanks, Tony
On Tue Oct 04 02:39:44 2005, tony@kasei.com wrote: Show quoted text
> On Thu, Sep 22, 2005 at 04:29:20AM -0400, Guest via RT wrote:
> > Seconded. This bug is still present in 2.42. Attached is a patch against > > 2.42 to fix it.
> > It'll be fixed much quicker with a patch to the test file to show the > problem. Obviously fixing the code isn't the problems. It's making sure > that this doesn't come back again. > > Thanks, > > Tony
Attached is a patch, with test (and it also fixes other test cases which have broken over time). Though I have to wonder... was it really better to leave this unfixed for almost 7 years, on the off chance that the problem would "come back again". Well, I guess if the problem never leaves in the first place, it can't come back, that's for sure...
Subject: asForm.patch
diff -ur Class-DBI-AsForm-2.42/lib/Class/DBI/AsForm.pm Class-DBI-AsForm-2.42-ak/lib/Class/DBI/AsForm.pm --- Class-DBI-AsForm-2.42/lib/Class/DBI/AsForm.pm 2005-09-07 00:24:26.000000000 +0200 +++ Class-DBI-AsForm-2.42-ak/lib/Class/DBI/AsForm.pm 2012-05-13 14:58:33.000000000 +0200 @@ -86,7 +86,7 @@ if ($how and $how =~ /^(text(area|field)|select)$/) { no strict 'refs'; my $meth = "_to_$how"; - return $class->$meth($field); + return $self->$meth($field); } my $hasa = $class->__hasa_rels->{$field}; return $self->_to_select($field, $hasa->[0]) diff -ur Class-DBI-AsForm-2.42/t/01.t Class-DBI-AsForm-2.42-ak/t/01.t --- Class-DBI-AsForm-2.42/t/01.t 2005-09-07 00:22:15.000000000 +0200 +++ Class-DBI-AsForm-2.42-ak/t/01.t 2012-05-13 14:57:50.000000000 +0200 @@ -1,7 +1,7 @@ package Foo; use Test::More; eval "require DBD::SQLite" or plan skip_all => "Couldn't load DBD::SQLite"; -plan tests => 4; +plan tests => 5; package DBI::Test; use base 'Class::DBI'; @@ -40,15 +40,20 @@ "Ordinary text field OK"); Foo->has_a(bar => Bar); -is(Foo->to_field("bar"), "<select name=\"bar\"><option value=1>Hi</option></select>\n", +is(Foo->to_field("bar"), "<select name=\"bar\"><option value=\"1\">Hi</option></select>\n", "Select OK"); my $x = bless({id => 1, bar => Bar->retrieve_all(), baz => "Hello there"}, "Foo"); -my %cgi = ( id => '<input name="id" type="text" value=1> +my %cgi = ( id => '<input name="id" type="text" value="1" /> ', - bar => '<select name="bar"><option selected value=1>Hi</option></select> + bar => '<select name="bar"><option selected value="1">Hi</option></select> ', - baz => '<input name="baz" type="text" value="Hello there"> + baz => '<input name="baz" type="text" value="Hello there" /> ' ); + +my %one = ( id => '<input name="id" type="text" value="1" /> +'); + is_deeply({$x->to_cgi}, \%cgi, "All correct as an object method"); +is_deeply({id => $x->to_field("id", "textfield")}, \%one, "Field with 'how' parameter correct");