[html-formfu] Creating a new record

Ascii King tech at swattermatter.com
Mon Mar 16 16:17:02 GMT 2009


I use the following code to call my formfu form.  When I want a new, 
empty record, I just call the sub with no parameters. It works well 
except for the repeatables. My repeatable elements on the form load 
every record in the 'many' table.
What am i doing wrong?

sub editprior : Local FormConfig('prior/editprior.yml') {
    my ($self, $c, $id) = @_;

    my $book;

    if (defined($id)) {
        $book = $c->model('DB::Prior')->find($id);

        unless ($book) {
            $c->stash->{error_msg} = "Invalid Character record -- Cannot 
edit";
            $c->response->redirect($c->uri_for('listprior'));
            $c->detach;
        }
    } else {
        $book = $c->model('DB::Prior')->new_result({});
    }

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

    if ($form->submitted_and_valid) {
        $form->model->update($book);
        $c->flash->{status_msg} = 'Record ammended';
        $c->response->redirect($c->uri_for('listprior'));
        $c->detach;
    } else {
        $form->model->default_values($book);
    }

    $c->stash->{template} = 'prior/editprior.tt2';
}




More information about the HTML-FormFu mailing list