[Catalyst] Error with create_from_form
Kevin Old
kevinold at gmail.com
Wed Jan 4 15:24:28 CET 2006
Hello everyone,
I'm playing around with the BookDB example
(http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/BookDB/)
and tried to add a book via the ISBN lookup feature. It's looked up
correctly, but when it do_add tries to insert into the database via
create_from_form I get this:
[Wed Jan 4 08:48:39 2006] [catalyst] [error] Caught exception "Can't
insert new BookDB::M::BookDB::Book: Cannot call execute with a
reference (ARRAY(0x996e178))
at /usr/lib/perl5/site_perl/5.8.6/Class/DBI/FromForm.pm line 64"
Here's the code in question:
sub do_add : Local {
my ( $self, $c ) = @_;
$c->form( required => [qw /title author/],
optional => [ BookDB::M::BookDB::Book->columns ] );
BookDB::M::BookDB::Book->create_from_form( $c->form );
$c->forward('list');
}
The info about the book is passed to do_add via do_add_from_isbn:
ub do_add_from_isbn : Local {
my ($self, $c) = @_;
my $ua = Net::Amazon->new(token => $c->config->{amazon_token} ||
'D13HRR2OQKD1Y5');
my $response = $ua->search( asin => $c->req->param('isbn') );
my ($prop) = $response->properties;
if ($response->is_success()) {
$c->error('Is success');
$c->req->param('title', $prop->title);
$c->req->param('publisher', $prop->publisher);
$c->req->param('year', $prop->year);
$c->req->param('author',join( "/", $prop->authors ) );
# Jump to the standard routine
$c->forward('do_add');
} else {
$c->error('Is NOT success');
$c->stash->{message} = "Object not found: ".$response->message();
$c->stash->{template} = 'Book/add.tt';
}
}
I can't figure out why it's not working. I've dumped the object and
there's plenty of good valid data in it.
Any suggestions?
Thanks,
Kevin
--
Kevin Old
kevinold at gmail.com
More information about the Catalyst
mailing list