[html-formfu] Re: Repeatable save problems

Lance A. Brown lance at bearcircle.net
Mon Apr 27 12:28:44 GMT 2009


Gerg Coates said the following on 4/26/2009 7:02 PM:
> And here's the relevant part of my Catalyst controller:
> 
> sub edit :Local :FormConfig('invoices/edit_invoice.yml') {
>   my ($self, $c, $ivc_id) = @_;
> 
>   if ($c->request->param('cancel')) {
>     $c->response->redirect($c->uri_for("/invoices"));
>     $c->detach();
>   }
> 
>   my $invoice = ($ivc_id) ? $c->model('DB::Invoices')->find($ivc_id)
>                           : $c->model('DB::Invoices')->new_result({});
> 
>   my $form = $c->stash->{form};
>   if ($form->submitted_and_valid()) {

>     $form->process();

I missed this the first time I looked through your code.  I don't think
you want to call process() here.


>     $form->model->update($invoice);
> 
>     if (! $c->request->param('draft')) {
>       # Save to accounts
>     }
> 

You probably want to add a call to $form->model->default_values($invoice);
here to load your invoice data into the form before displaying it.

>     $c->response->redirect($c->uri_for("/invoices"));
>     $c->detach();
>   }
> }


-- 
 GPG Fingerprint: 409B A409 A38D 92BF 15D9 6EEE 9A82 F2AC 69AC 07B9
 CACert.org Assurer



More information about the HTML-FormFu mailing list