[html-formfu] wrong err msg because of detach to another form

David Schmidt davewood at gmx.at
Tue Dec 1 20:52:24 GMT 2009


Hello

In my Cat App I show two forms to the User. The problem now is that
when I submitted a valid form #1 my app detaches to form #2 where
error messages are displayed according to the parameters of form #1
which are still in the request.

I've been looking in the CPAN docs but couldnt find anything related to that.

sub show :Path('show') :Args(1) {
    my ( $self, $c, $form_config) = @_;

    # set the form
    my $form = $self->form;
    $form->load_config_file($form_config);
    $form->process;

    if ($form->submitted_and_valid &&
(!(defined($c->stash->{dont_process_form})))) {
        # make sure the same form isn't processed twice
        # by using the dont_process_form var

        ##########################
        # do stuff with form data
        # and manipulate session
        ##########################

        # otherwise deep recursion
        $c->stash->{dont_process_form} = 1;
        $c->detach($c->controller('Root')->action_for('index'));
    } else {
        $c->stash->{form} = $form;
    }
}

In Root::index I dispatch to the required forms according to a
session variable that indicates the state of the user.

david



More information about the HTML-FormFu mailing list