FAQ
I don't know whether someone has asked it yet.

here is my situation.

I have an action "find" that take one argument of book id
and I have another action author that chained to find
so in practice I use /find/1/author to list all the authors of book 1.

now I want to capture the book id use form but still use the action "find"
and "author"
so in action "form_do",
I use
$c->response->redirect($c->uri_for("/find/$book_id/author"));

but I have learned that $c->uri_for($self->action_for('author')*** should be
a better approach.
so how do I parse the $book_id if I don't want to hard code the URL.

Thank you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100318/e7950e36/attachment.htm

Search Discussions

  • Ali Mesdaq at Mar 18, 2010 at 7:34 pm
    �so how do I parse the $book_id if I don't want to hard code the URL.�

    I am a little confused by that statement. What do you mean parse $book_id you already know the book_id. Are you basically trying to redirect the user back to the URL they came from?

    Thanks,
    ------------------------------------------
    Ali Mesdaq (CISSP, GIAC-GREM)
    Sr. Security Researcher
    Websense Security Labs
    http://www.WebsenseSecurityLabs.com<http://www.websensesecuritylabs.com/>
    ------------------------------------------

    From: nhyda
    Sent: Thursday, March 18, 2010 9:38 AM
    To: Catalyst@lists.scsys.co.uk
    Subject: [Catalyst] using uri_for to parsing parameters

    I don't know whether someone has asked it yet.

    here is my situation.

    I have an action "find" that take one argument of book id
    and I have another action author that chained to find
    so in practice I use /find/1/author to list all the authors of book 1.

    now I want to capture the book id use form but still use the action "find" and "author"
    so in action "form_do",
    I use
    $c->response->redirect($c->uri_for("/find/$book_id/author"));

    but I have learned that $c->uri_for($self->action_for('author')*** should be a better approach.
    so how do I parse the $book_id if I don't want to hard code the URL.

    Thank you very much.


    Click here<https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==> to report this email as spam.


    Protected by Websense Hosted Email Security -- www.websense.com
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100318/e4d1ae2c/attachment.htm
  • Jay Shirley at Mar 18, 2010 at 8:02 pm

    On Thu, Mar 18, 2010 at 9:38 AM, nhyda wrote:
    I don't know whether someone has asked it yet.

    here is my situation.

    I have an action "find" that take one argument of book id
    and I have another action author that chained to find
    so in practice I use /find/1/author to list all the authors of book 1.

    now I want to capture the book id use form but still use the action "find"
    and "author"
    so in action "form_do",
    I use
    $c->response->redirect($c->uri_for("/find/$book_id/author"));

    but I have learned that $c->uri_for($self->action_for('author')*** should be
    a better approach.
    so how do I parse the $book_id if I don't want to hard code the URL.

    Thank you very much.

    If you are truly using Chained (as the Dispatch type) and it is a
    CaptureArg, you would be able to use:
    $c->uri_for_action('/find/author', [ $book_id ]);

    The syntax is pretty simple:
    $c->uri_for_action( '/action/path', [ @captures ], @arguments, { query
    => 'param' } );

    This works if you are using Chained and CaptureArgs(...) and Args(...)
    in your action definition.

    -J

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMar 18, '10 at 4:38p
activeMar 18, '10 at 8:02p
posts3
users3
websitecatalystframework.org
irc#catalyst

3 users in discussion

Ali Mesdaq: 1 post Nhyda: 1 post Jay Shirley: 1 post

People

Translate

site design / logo © 2021 Grokbase