[html-formfu] Re: DBIC::Validation::FormFu RFC & Element::Date patch

Carl Franks fireartist at gmail.com
Mon Oct 22 21:12:53 GMT 2007


At first, I liked the look of how the REST Action handled things (I'd
never looked into it before).
However, thinking about it further, the kind of things I would
typically do in the GET routine, would usually also be necessary in
the POST routine if the form's needing to be redisplayed.
What use cases make it worth the added complexity?

> sub root : Chained('base') PathPart('') Args(0) REST {}
>
> # Show the Form to create a new entry
> sub root_GET {
>     my ( $self, $c ) = @_;
>     $c->stash(form => $self->model->form);
> }
>
> # Get the data from the form and redisplay with errors if invalid
> # or redirect to a success page if valid
> sub root_POST : MyAction('CheckError') {
>     my ( $self, $c ) = @_;
>     my $new = $self->model->create($c->req->params);
>     $c->redirect($self->create_uri);
> }

Compared to the above 3 routines, I think I still prefer:

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

    if ( $self->stash->{form}->submitted_and_valid ) {
        $self->model->new->populate_from_formfu( $c->stash->{form} );
        $c->response->redirect($c->uri_for('done'));
    }
}

Would you mind posting the code you have so far for DBIC::Validation::FormFu ?

Carl



More information about the HTML-FormFu mailing list