[Catalyst] Any recommendations for multiple forms in catalyst (have been using HTML::FormFu)?

kakimoto at tpg.com.au kakimoto at tpg.com.au
Tue Jul 15 14:13:34 BST 2008

 I was pretty successful in keeping things simple.

 I figured I d' keep all steps that needed a form to be generated (ie
for data entry) to "sub create".

Then, at the very end when I am done getting all the data (from forms
shown on the webpage), I would then
redirect/forward/detach to another method, "sub save_complete_listing".

sub create :Local  :FormMethod('_get_dynamic_form') { 
    my ($self, $c) = @_;

    # Set the template
    my $effective_template = 'listings/create.tt2';
    $c->stash->{template} = $effective_template;
    my $loanType = lc($c->request->param('loanType'));

    my $step = $c->flash->{step};
    $c->log->debug("Current operation: $step");

    if (defined($step) and $step =~ m/\w+/)
        my $form_submission_success = $c->stash->{'form'}->submitted();
        if ($form_submission_success) {

            if ($step eq 'first_step')

             # now, set the next step.
              $c->flash->{'step'} = 'second_step';
           elsif ($step eq 'second_step')

             # now, set the next step.
              $c->flash->{'step'} = 'third_step';

           elsif ($step eq 'third_step')

             # now, we have acquired all data we need from steps one and
             # we do a redirect/forward/detach to save the values. 
Should go to 'sub save_complete_listing'

             $c->detach/ $c->res->forward/$c->redirect   # all failed.

 A few questions:

1) What is the difference between Detach, forward and redirect?? I read
through the docos and they are under explained.
   Refered to

    Correct me if i am wrong:
    a) $c->forward - control will be passed to whatever target it is
defined with. Once the target is finished with execution, control will
go back to where it was "forwarded" from

   b) $c->detach - same as forward BUT control does not go back to where
it was "detached" from.

   c) $c->res->redirect - someone please give me an idea cause my
initial thoughts was that it should resemble forward

2. When we do a $c->forward/$c->detach/$c->res->redirect,  would
     a) $c still be defined??
     b) $c->stash contents still be defined??
     c) $c->flash contents still be defined??

  For stash and flash, I noticed they got wiped off. Particularly,
To be extra safe, before the $c->forward/$c->detach/$c->res->redirect,
I even explicitly did a "$c->flash->{'form'} = $c->stash->{'form'}" and
 yet the values have dissappeared.

 Please help.


More information about the Catalyst mailing list