Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the HTML-FormHandler CPAN distribution.

Report information
The Basics
Id: 68806
Status: resolved
Priority: 0/
Queue: HTML-FormHandler

People
Owner: Nobody in particular
Requestors: stephen.thirlwall [...] strategicdata.com.au
Cc:
AdminCc:

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



Subject: Date fields broken when creating DBIC form with new result
Download (untitled) / with headers
text/plain 982b
Hello, I believe I have discovered a bug in HTML::FormHandler::Field::Date.pm To reproduce: * create a HTML::FormHandler::Model::DBIC form with a Date field. * create a new database row with $row = $resultset->new_result( {} ); * process the form as: $form->process( item => $row ); Dies with: Can't call method "value" on an undefined value at html-formhandler/lib/HTML/FormHandler/Field.pm line 740 Same code worked in 0.34000 and before. Works if a DateTime field is used instead of a Date field. The problem was introduced in this revision: https://github.com/gshank/html-formhandler/commit/e95858fb97031c7747e3a92f8c109939b4b113e2 Although I think that change merely exposed an existing problem. I will attach some test code and a possible fix shortly. Version information: HTML-FormHandler-0.34001 This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-linux-thread-multi Debian 5 2.6.32-4-pve #1 SMP Mon May 9 12:59:57 CEST 2011 x86_64 GNU/Linux
From: stephen.thirlwall [...] strategicdata.com.au
Download (untitled) / with headers
text/plain 1.2k
I've created a two related pull requests on github The first contains test code which exercises the problem: https://github.com/gshank/html-formhandler-model-dbic/pull/1 I've created t/Date.t which contains three tests. The first two work as expected, the third triggers the bug in question. I've added similar tests to t/DateTime.t to show the same code works for DateTime fields. The second contains a possible fix: https://github.com/gshank/html-formhandler/pull/16 I really cannot explain what is happening here. I arrived at this fix by comparing Field/Date.pm and Field/DateTime.pm. The only real difference I could see was that DateTime.pm wasn't defaulting the $value parameter to $self-value. I tried removing that line from Field/Date.pm and this seems to have fixed it. The place where the code dies is in Field.pm, line 740 sub value { my $self = shift; # allow testing fields individually by creating result if no form return undef unless $self->has_result || !$self->form; my $result = $self->result; return $result->_set_value(@_) if @_; return $result->value; } I'm not 100% certain of what is going on, but it seems $self->has_result returns true, but $self->result is undef. Thanks, Stephen Thirlwall
Thanks for the report. This bug is fixed (in a couple of ways) in the upcoming release.


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.