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';
}


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to