On Wed, Mar 5, 2008 at 3:05 PM, Ian Sillitoe <[EMAIL PROTECTED]> wrote: > > Controller/TableA.pm: > $c->{stash}->{row_a} = $c->model('MyDBIC::TableA')->find('id'); > $c->{stash}->{template} = 'view_a.tt2'; > $c->forward('Catalyst::View::TT'); > > /root/src/view_a.tt2: > [% rows_b = row_a.get_related_rows( optional => param ) %] > [% FOREACH row_b = rows_b %] > [% DisplayRow(row_b) %] > [% END %] >
Perhaps there should be no need for the custom get_related_rows call (and doing in the template should be, in fact, breaking MVC principles, IMHO). If your DBIC Classes representing TableA and TableB are properly related (master-detail, in this case, for what shows from the example, something like: TableA has_many TableB) with the method, say, gimme_b, something like the following should work: /root/src/view_a.tt2: [% rows_b = row_a.gimme_b %] [% FOREACH row_b = rows_b %] [% DisplayRow(row_b) %] [% END %] If, for some odd reason, the DBIC Relationships (a definite _must see_ on the docs) are not enough for your needs, you could put all your related rows from TableB on the stash (calling the custom model method from your controller), so you don't make direct calls from your template to your models. Anyway, that's just an opinion. HTH. _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/