[Catalyst] putting an object in the stash

Octavian Rasnita orasnita at gmail.com
Tue Mar 13 10:37:12 GMT 2007


Hi,

I have a DBIC record object like
my $obj = $c->model("Database::Table")->find($id);

The table has very many fields and I would like to put their values in a TT 
template without inserting them one by one in the stash.

So I would like to create a hash ref from $obj where the name of the field 
is the key and the value from the table is the value in that hash, then use 
$c->stash($hashref).

Is it possible to create that hash (ref) from $obj, or I need to do 
something like

$c->stash->{obj} = $obj;

and in the template use [% obj.name1 %]... [% obj.name2 %]?

And by the way, which do you think is the recommended way?

Thank you.




Octavian




More information about the Catalyst mailing list