[Catalyst] Question on parameter passing

Peter Sørensen maspsr at sdu.dk
Mon Feb 18 11:17:34 GMT 2008


Hi,

Using Catalyst, TT and FormBuilder

I have a question concerning parameter passing.

I have an action lists/editlist

which display a form based on a TT template. In this form the user can
modify several field and hit the SUBMIT button to update theese fields. 

sub editlist : Local Form {
        my ($self, $c) = @_;
        my $data = $c->req->params;
        my $form = $self->form->new(debug => 0);

        my $listmembers = $c->model('CatalystModelName::ListsAlias')
                                        ->find({'listname' => $data->{listname} } );

        # populate the fields
        $form->field(name => 'date', value => $listmembers->date);
        $form->field(name => 'reason', value => $listmembers->reason);
        $form->field(name => 'by', value => $listmembers->created_by);
        $form->field(name => 'listname', value => $data->{listname});
     
        # Make information available for the template
        my @membersarray = split(" ",$listmembers->destination);
        my @popdesc = $listmembers->population_desc;

        $c->stash->{listname} = $data->{listname};
        $c->stash->{members} = \@membersarray;
        $c->stash->{popdesc} = \@popdesc;
        $c->stash->{created_by} = $listmembers->created_by;
        $c->stash->{template} = 'editlist.tt2';
}





The SUBMIT call a new action lists/savemembers where the update 
according to a database is done.


The savemembers don't output anything just processing data. I would like
it to stay in the same form after data are processed.

I have tried several ways make the nessacary information available to this:

	use the stash ( does'nt work and is probably not the right way to deal with this. Tried to 
                      pass the listname. Thought that this information would be available to another
                      process in the controller)

      use hidden form fields: works but there must be a cleaner way to do this.


How do I deal with this in a proper way using catalyst? And how do I process the data and 
leave the form unchanged?


Regards and thanks

Peter Sorensen/University of Southern Denmark/mail: maspsr at sdu.dk




More information about the Catalyst mailing list