[Catalyst] Not really a catalyst matter

Roland Moriz roland at moriz.de
Wed Nov 9 00:03:52 CET 2005


Hello Will,

Will Smith schrieb:
> this question is kind of dumb, but it just does not work for me
>  
> my $artist= cd::M::CDBI::Artist->search(name=>$c->req->param(myartist));
>  
> on the template, if i choose to submit the form with the field named 
> "myartist", it works fine. But if I use the onchange event for that same 
> field, a select box (or text box), it says that:
>  
> [Tue Nov  8 17:28:40 2005] [catalyst] [error] Caught exception "Can't 
> use string
>  ("name") as a HASH ref while "strict refs" in use at 
> C:/Perl/site/lib/Class/DBI
> .pm line 1091."

try to debug it like that way:

use Data::Dumper;

sub youraction : .... {
my (... $c ... ) @_;

my $log = $c->log();
my $myartist = $c->req->param('myartist');

$log->debug( Dumper($myartist) );

[...]

}

You should see the content of $myartist in the log. I guess the reason 
of your problem is that param myartist has no value...

(Check the Data::Dumper and Catalyst::Log manual:

http://search.cpan.org/~ilyam/Data-Dumper-2.121/Dumper.pm
http://search.cpan.org/~mramberg/Catalyst-5.33/lib/Catalyst/Log.pm
)


Another hint: search() from Class::DBI may return more than one result.

So beside your current problem try:

my $artist3 = Music::Artist->search( name => 'Polysics' )->first;

you'll only get the first result. if you want to process more results 
you'll have to put it into an array and/or loop the result ... (as 
described in the Class::DBI manual)


Mit freundlichen Gruessen,
with best regards,

Roland Moriz

--
http://www.perl-freelancer.com/
http://www.roland-moriz.de/



More information about the Catalyst mailing list