[Catalyst] Catalyst actions

Richard Jones ra.jones at dpw.clara.co.uk
Fri May 18 09:33:29 GMT 2007


Matt S Trout wrote:
>> Couldn't render template "file error - search/search: not found"
> 
> And as documented, View::TT uses the private path to determine the default
> template.
> 
> $c->stash(template => 'search');
> 
> would override that.

It does, and I'm nearly there now. Providing I set the template name in 
stash before $c->detach('search'), it re-loads the search page *with* 
the query params, *and* displays the message.

But for some reason it doesn't build the form properly, as the drop-down 
menus are empty - these are generated in the search() method using a 
formbuilder object pulled in from a My::Formbuilder module which does 
the form generation. Apart from that the form looks and behaves 
correctly, providing I use $c->detach (see below).

>> I also sometime see [% Catalyst.uri_for('search') %] translating to
>> 'base_url/search/search' in the template, and though ugly, it does work.
> 
> That's cuz it generates a URI relative to the current namespace. I'd generally
> avoid passing strings to uri_for except for static files, and instead pass
> $controller->action_for($name_of_action_method).

But it's in the template I'm using uri_for, and action_for doesn't seem 
to work there ie [% Catalyst.action_for('search') %]

>> I've also tried playing with calling the default method 'index' and
>> 'default', and various attributes Local, Path, Global (I know that one's
>> wrong) but ran into problems with all of those. I can't do a
>> $c->res->redirect to the url '/search' as I need the original search
>> params reloading. Can anyone see an obvious solution to this? Probably
>> to do it the correct way!
> 
> $c->uri_for($self->action_for('search'), $c->req->query_parameters); ?

That also gets the form re-displayed, but without the query_params and 
without the 'Submit' button, which is generated in the template as part 
of the form object ie [% form.submit %]. Any further thoughts? Thanks 
for your help so far btw :-)
-- 
Richard Jones



More information about the Catalyst mailing list