2008/5/29 <[EMAIL PROTECTED]>: > 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 tab. > 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 behaviour. > 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 return; } Carl _______________________________________________ HTML-FormFu mailing list HTML-FormFu@lists.scsys.co.uk http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu