[html-formfu] Redirection after an error

hallouina-formfu at yahoo.fr hallouina-formfu at yahoo.fr
Fri May 30 21:06:27 BST 2008

Hi Carl,

You help me when you talk about the form action. I change it to http://localhost:3000/person/view/1#tab1 and now it's working :). I notice you are the owner of FormFu. Thanks for your job it should be very long and hard to produce this super module.

Thanks for you help and your attention.


----- Message d'origine ----
De : Carl Franks <fireartist at gmail.com>
À : "HTML Form Creation, Rendering and Validation Framework" <html-formfu at lists.scsys.co.uk>
Envoyé le : Vendredi, 30 Mai 2008, 16h55mn 43s
Objet : Re: [html-formfu] Redirection after an error

2008/5/29  <hallouina-formfu at yahoo.fr>:
> Hello,
> I have a web page splitted into 3 tabs. I have a form on the first tab. On the second tab I display a list of object from a table. I can add object in the second tab with FormFu and I redirect to this second tab after the validation (here :  http://localhost:3000/person/view/1#tab2 ). It works fine.

Hi Antoine,

I'm guessing you're using a JS library to fake tabs within a single
page, but you don't explain whether the content for the tabs comes
from the original html file, or whether it loads a new url for each

> And I fill my form in the first tab. If my form isn't full fill, i get this message : "This field is required". But i'm redirect from the prefious url : the second tab. I suppose this is because the default FormFu behavior is to redirect to the previous url in case of error. To avoid this problem I add this line to my controller :

HTML-FormFu doesn't know anything about redirects - that's purely
dependant on your web-framework.
I'm guessing your form is using the same URL for it's "action"
attribute as is used to display the form - that would explain this

>        if ($form->submitted && $form->has_errors) {
>                $c->response->redirect($c->uri_for("/person/view/$id_person#tab1")); $c->detach;
>        }

If you want to display errors, you can't do a redirect - as that makes
the client's browser make a new request to to the server, and the
previously submitted data is lost.
I normally just do this (with Catalyst):

sub foo {
    my ( $self, $c ) = @_;

    my $form = $self->stash->{form};

    if ( $form->submitted_and_valid ) {
        # no errors - do processing stuff

    # if there are errors, it'll just fall through to here, and
redisplay the form



Do You Yahoo!?
En finir avec le spam? Yahoo! Mail vous offre la meilleure protection possible contre les messages non sollicités 
http://mail.yahoo.fr Yahoo! Mail 

More information about the HTML-FormFu mailing list